From nobody Fri Apr 19 22:10:55 2024 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=1609968910; cv=none; d=zohomail.com; s=zohoarc; b=IrC+ank5SUaouIjuDxeXJOzMkVj5cd+2j4Cd8oRl/tTEjjIVk1jKmGc+LzMldnXdpT4j+ySpaED9iPFIvDo3QQZhY/nXgiT+T4f6ytREcx0Z1EtnamfuMFx1uxYwb2xcOWAzYvfMUsdvgKLxCXBHYIoReCvIC1ipjWH63mrbdjM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609968910; 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=WHFOSMKWAhZPmpZAANPGNKP2hOQYBufdgR6yKnJMQxE=; b=JaBxCyXz5gX+pYtlO+qFepOHdZnozG4Yis/1ZC0EPYNebSxErs0RGXJ0zk5NGJYuVsASlEAk6hYG2/4cijYh92WvsHq81oZeRixn4RBN8e/fTm4KUXgQfm2ojvWjU3XwG+GIq6LInwpenhdBaoAUdBk8qtlWSaQFwn1DjRZc8LY= 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 1609968910302258.04593997492645; Wed, 6 Jan 2021 13:35:10 -0800 (PST) Received: from localhost ([::1]:54916 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGST-0001fO-57 for importer@patchew.org; Wed, 06 Jan 2021 16:35:09 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMW-0002r0-Sf for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:00 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:22456) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMO-0001j2-If for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:00 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 45BB3747100; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 16A167470F5; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: <00e13d203010a8e2b9b995df4675ce5df184025e.1609967638.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 01/12] vt82c686: Move superio memory region to SuperIOConfig struct Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The superio memory region holds the io space index/data registers used to access the superio config registers that are implemented in struct SuperIOConfig. To keep these related things together move the memory region to SuperIOConfig and rename it accordingly. Also remove the unused "data" member of SuperIOConfig which is not needed as we store actual data values in the regs array. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index a6f5a0843d..30fe02f4c6 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -29,12 +29,11 @@ typedef struct SuperIOConfig { uint8_t regs[0x100]; uint8_t index; - uint8_t data; + MemoryRegion io; } SuperIOConfig; =20 struct VT82C686BISAState { PCIDevice dev; - MemoryRegion superio; SuperIOConfig superio_cfg; }; =20 @@ -128,8 +127,9 @@ static void vt82c686b_write_config(PCIDevice *d, uint32= _t addr, =20 trace_via_isa_write(addr, val, len); pci_default_write_config(d, addr, val, len); - if (addr =3D=3D 0x85) { /* enable or disable super IO configure */ - memory_region_set_enabled(&s->superio, val & 0x2); + if (addr =3D=3D 0x85) { + /* BIT(1): enable or disable superio config io ports */ + memory_region_set_enabled(&s->superio_cfg.io, val & BIT(1)); } } =20 @@ -311,15 +311,15 @@ static void vt82c686b_realize(PCIDevice *d, Error **e= rrp) } } =20 - memory_region_init_io(&s->superio, OBJECT(d), &superio_cfg_ops, - &s->superio_cfg, "superio", 2); - memory_region_set_enabled(&s->superio, false); + memory_region_init_io(&s->superio_cfg.io, OBJECT(d), &superio_cfg_ops, + &s->superio_cfg, "superio_cfg", 2); + memory_region_set_enabled(&s->superio_cfg.io, false); /* * The floppy also uses 0x3f0 and 0x3f1. * But we do not emulate a floppy, so just set it here. */ memory_region_add_subregion(isa_bus->address_space_io, 0x3f0, - &s->superio); + &s->superio_cfg.io); } =20 static void via_class_init(ObjectClass *klass, void *data) --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609969207; cv=none; d=zohomail.com; s=zohoarc; b=Sn3DLVxtF2m5P0bDqnKxTlQrCAAP9MVoMxKPHCxChRgZJRVtzFQRsbnQvtRw5yoli0jP4KRhCWbTRgN2QzYG4uqstO+9Sb2TTMvFLSONLvPTHJDS/DJHLUYYtzsUX9oACMKDnLBFzsSCjcv5+vTPjJdLJBBtbVasn7v33NN7kBs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609969207; 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=+t7Nz1LLlXiibYYf7dllZVrqL9156mPT8HUmSQEx4oY=; b=epB74IVhG9FMQ9jcz/Az4XnHhwdLfk92JuXTQGicnWuAd30JsiFGaSUKFVlrXO9KyB8jNk2lw2fR9YkU8G/KcslLzGrnowFobWEse0FuCDhEKK/zX8g0PZSi+HPI2nzZ1sTvcvgEmC+2MbTAUcNmg0dkLujiujWMisvb7c3bQGM= 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 1609969207675132.6951814412314; Wed, 6 Jan 2021 13:40:07 -0800 (PST) Received: from localhost ([::1]:37782 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGXG-0006Qd-HM for importer@patchew.org; Wed, 06 Jan 2021 16:40:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57782) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMZ-0002x9-Na for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:03 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:22501) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMW-0001la-B2 for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:03 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id A06CE7475FD; Wed, 6 Jan 2021 22:28:58 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 1BDD77470F3; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 02/12] vt82c686: Reorganise code Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Move lines around so that object definitions become consecutive and not scattered around. This brings functions belonging to an object together so it's clearer what is defined and what parts belong to which object. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/isa/vt82c686.c | 279 +++++++++++++++++++++++----------------------- 1 file changed, 140 insertions(+), 139 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 30fe02f4c6..fe8961b057 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -26,112 +26,7 @@ #include "exec/address-spaces.h" #include "trace.h" =20 -typedef struct SuperIOConfig { - uint8_t regs[0x100]; - uint8_t index; - MemoryRegion io; -} SuperIOConfig; - -struct VT82C686BISAState { - PCIDevice dev; - SuperIOConfig superio_cfg; -}; - -OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA) - -static void superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, - unsigned size) -{ - SuperIOConfig *sc =3D opaque; - - if (addr =3D=3D 0x3f0) { /* config index register */ - sc->index =3D data & 0xff; - } else { - bool can_write =3D true; - /* 0x3f1, config data register */ - trace_via_superio_write(sc->index, data & 0xff); - switch (sc->index) { - case 0x00 ... 0xdf: - case 0xe4: - case 0xe5: - case 0xe9 ... 0xed: - case 0xf3: - case 0xf5: - case 0xf7: - case 0xf9 ... 0xfb: - case 0xfd ... 0xff: - can_write =3D false; - break; - /* case 0xe6 ... 0xe8: Should set base port of parallel and serial= */ - default: - break; - - } - if (can_write) { - sc->regs[sc->index] =3D data & 0xff; - } - } -} - -static uint64_t superio_cfg_read(void *opaque, hwaddr addr, unsigned size) -{ - SuperIOConfig *sc =3D opaque; - uint8_t val =3D sc->regs[sc->index]; - - trace_via_superio_read(sc->index, val); - return val; -} - -static const MemoryRegionOps superio_cfg_ops =3D { - .read =3D superio_cfg_read, - .write =3D superio_cfg_write, - .endianness =3D DEVICE_NATIVE_ENDIAN, - .impl =3D { - .min_access_size =3D 1, - .max_access_size =3D 1, - }, -}; - -static void vt82c686b_isa_reset(DeviceState *dev) -{ - VT82C686BISAState *s =3D VT82C686B_ISA(dev); - uint8_t *pci_conf =3D s->dev.config; - - pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); - pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMO= RY | - PCI_COMMAND_MASTER | PCI_COMMAND_SPECIAL); - pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM); - - pci_conf[0x48] =3D 0x01; /* Miscellaneous Control 3 */ - pci_conf[0x4a] =3D 0x04; /* IDE interrupt Routing */ - pci_conf[0x4f] =3D 0x03; /* DMA/Master Mem Access Control 3 */ - pci_conf[0x50] =3D 0x2d; /* PnP DMA Request Control */ - pci_conf[0x59] =3D 0x04; - pci_conf[0x5a] =3D 0x04; /* KBC/RTC Control*/ - pci_conf[0x5f] =3D 0x04; - pci_conf[0x77] =3D 0x10; /* GPIO Control 1/2/3/4 */ - - s->superio_cfg.regs[0xe0] =3D 0x3c; /* Device ID */ - s->superio_cfg.regs[0xe2] =3D 0x03; /* Function select */ - s->superio_cfg.regs[0xe3] =3D 0xfc; /* Floppy ctrl base addr */ - s->superio_cfg.regs[0xe6] =3D 0xde; /* Parallel port base addr */ - s->superio_cfg.regs[0xe7] =3D 0xfe; /* Serial port 1 base addr */ - s->superio_cfg.regs[0xe8] =3D 0xbe; /* Serial port 2 base addr */ -} - -/* write config pci function0 registers. PCI-ISA bridge */ -static void vt82c686b_write_config(PCIDevice *d, uint32_t addr, - uint32_t val, int len) -{ - VT82C686BISAState *s =3D VT82C686B_ISA(d); - - trace_via_isa_write(addr, val, len); - pci_default_write_config(d, addr, val, len); - if (addr =3D=3D 0x85) { - /* BIT(1): enable or disable superio config io ports */ - memory_region_set_enabled(&s->superio_cfg.io, val & BIT(1)); - } -} +OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM) =20 struct VT686PMState { PCIDevice dev; @@ -142,30 +37,6 @@ struct VT686PMState { uint32_t smb_io_base; }; =20 -OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM) - -static void pm_update_sci(VT686PMState *s) -{ - int sci_level, pmsts; - - pmsts =3D acpi_pm1_evt_get_sts(&s->ar); - sci_level =3D (((pmsts & s->ar.pm1.evt.en) & - (ACPI_BITMASK_RT_CLOCK_ENABLE | - ACPI_BITMASK_POWER_BUTTON_ENABLE | - ACPI_BITMASK_GLOBAL_LOCK_ENABLE | - ACPI_BITMASK_TIMER_ENABLE)) !=3D 0); - pci_set_irq(&s->dev, sci_level); - /* schedule a timer interruption if needed */ - acpi_pm_tmr_update(&s->ar, (s->ar.pm1.evt.en & ACPI_BITMASK_TIMER_ENAB= LE) && - !(pmsts & ACPI_BITMASK_TIMER_STATUS)); -} - -static void pm_tmr_timer(ACPIREGS *ar) -{ - VT686PMState *s =3D container_of(ar, VT686PMState, ar); - pm_update_sci(s); -} - static void pm_io_space_update(VT686PMState *s) { uint32_t pm_io_base; @@ -179,12 +50,6 @@ static void pm_io_space_update(VT686PMState *s) memory_region_transaction_commit(); } =20 -static void pm_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int= len) -{ - trace_via_pm_write(addr, val, len); - pci_default_write_config(d, addr, val, len); -} - static int vmstate_acpi_post_load(void *opaque, int version_id) { VT686PMState *s =3D opaque; @@ -210,7 +75,34 @@ static const VMStateDescription vmstate_acpi =3D { } }; =20 -/* vt82c686 pm init */ +static void pm_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int= len) +{ + trace_via_pm_write(addr, val, len); + pci_default_write_config(d, addr, val, len); +} + +static void pm_update_sci(VT686PMState *s) +{ + int sci_level, pmsts; + + pmsts =3D acpi_pm1_evt_get_sts(&s->ar); + sci_level =3D (((pmsts & s->ar.pm1.evt.en) & + (ACPI_BITMASK_RT_CLOCK_ENABLE | + ACPI_BITMASK_POWER_BUTTON_ENABLE | + ACPI_BITMASK_GLOBAL_LOCK_ENABLE | + ACPI_BITMASK_TIMER_ENABLE)) !=3D 0); + pci_set_irq(&s->dev, sci_level); + /* schedule a timer interruption if needed */ + acpi_pm_tmr_update(&s->ar, (s->ar.pm1.evt.en & ACPI_BITMASK_TIMER_ENAB= LE) && + !(pmsts & ACPI_BITMASK_TIMER_STATUS)); +} + +static void pm_tmr_timer(ACPIREGS *ar) +{ + VT686PMState *s =3D container_of(ar, VT686PMState, ar); + pm_update_sci(s); +} + static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) { VT686PMState *s =3D VT82C686B_PM(dev); @@ -276,6 +168,87 @@ static const TypeInfo via_pm_info =3D { }, }; =20 + +typedef struct SuperIOConfig { + uint8_t regs[0x100]; + uint8_t index; + MemoryRegion io; +} SuperIOConfig; + +static void superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, + unsigned size) +{ + SuperIOConfig *sc =3D opaque; + + if (addr =3D=3D 0x3f0) { /* config index register */ + sc->index =3D data & 0xff; + } else { + bool can_write =3D true; + /* 0x3f1, config data register */ + trace_via_superio_write(sc->index, data & 0xff); + switch (sc->index) { + case 0x00 ... 0xdf: + case 0xe4: + case 0xe5: + case 0xe9 ... 0xed: + case 0xf3: + case 0xf5: + case 0xf7: + case 0xf9 ... 0xfb: + case 0xfd ... 0xff: + can_write =3D false; + break; + /* case 0xe6 ... 0xe8: Should set base port of parallel and serial= */ + default: + break; + + } + if (can_write) { + sc->regs[sc->index] =3D data & 0xff; + } + } +} + +static uint64_t superio_cfg_read(void *opaque, hwaddr addr, unsigned size) +{ + SuperIOConfig *sc =3D opaque; + uint8_t val =3D sc->regs[sc->index]; + + trace_via_superio_read(sc->index, val); + return val; +} + +static const MemoryRegionOps superio_cfg_ops =3D { + .read =3D superio_cfg_read, + .write =3D superio_cfg_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; + + +OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA) + +struct VT82C686BISAState { + PCIDevice dev; + SuperIOConfig superio_cfg; +}; + +static void vt82c686b_write_config(PCIDevice *d, uint32_t addr, + uint32_t val, int len) +{ + VT82C686BISAState *s =3D VT82C686B_ISA(d); + + trace_via_isa_write(addr, val, len); + pci_default_write_config(d, addr, val, len); + if (addr =3D=3D 0x85) { + /* BIT(1): enable or disable superio config io ports */ + memory_region_set_enabled(&s->superio_cfg.io, val & BIT(1)); + } +} + static const VMStateDescription vmstate_via =3D { .name =3D "vt82c686b", .version_id =3D 1, @@ -286,7 +259,33 @@ static const VMStateDescription vmstate_via =3D { } }; =20 -/* init the PCI-to-ISA bridge */ +static void vt82c686b_isa_reset(DeviceState *dev) +{ + VT82C686BISAState *s =3D VT82C686B_ISA(dev); + uint8_t *pci_conf =3D s->dev.config; + + pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); + pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMO= RY | + PCI_COMMAND_MASTER | PCI_COMMAND_SPECIAL); + pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM); + + pci_conf[0x48] =3D 0x01; /* Miscellaneous Control 3 */ + pci_conf[0x4a] =3D 0x04; /* IDE interrupt Routing */ + pci_conf[0x4f] =3D 0x03; /* DMA/Master Mem Access Control 3 */ + pci_conf[0x50] =3D 0x2d; /* PnP DMA Request Control */ + pci_conf[0x59] =3D 0x04; + pci_conf[0x5a] =3D 0x04; /* KBC/RTC Control*/ + pci_conf[0x5f] =3D 0x04; + pci_conf[0x77] =3D 0x10; /* GPIO Control 1/2/3/4 */ + + s->superio_cfg.regs[0xe0] =3D 0x3c; /* Device ID */ + s->superio_cfg.regs[0xe2] =3D 0x03; /* Function select */ + s->superio_cfg.regs[0xe3] =3D 0xfc; /* Floppy ctrl base addr */ + s->superio_cfg.regs[0xe6] =3D 0xde; /* Parallel port base addr */ + s->superio_cfg.regs[0xe7] =3D 0xfe; /* Serial port 1 base addr */ + s->superio_cfg.regs[0xe8] =3D 0xbe; /* Serial port 2 base addr */ +} + static void vt82c686b_realize(PCIDevice *d, Error **errp) { VT82C686BISAState *s =3D VT82C686B_ISA(d); @@ -354,6 +353,7 @@ static const TypeInfo via_info =3D { }, }; =20 + static void vt82c686b_superio_class_init(ObjectClass *klass, void *data) { ISASuperIOClass *sc =3D ISA_SUPERIO_CLASS(klass); @@ -372,11 +372,12 @@ static const TypeInfo via_superio_info =3D { .class_init =3D vt82c686b_superio_class_init, }; =20 + static void vt82c686b_register_types(void) { type_register_static(&via_pm_info); - type_register_static(&via_superio_info); type_register_static(&via_info); + type_register_static(&via_superio_info); } =20 type_init(vt82c686b_register_types) --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609969121; cv=none; d=zohomail.com; s=zohoarc; b=HqLLhqaF7BV77BjiKMMf6lfji8a8IwV9+aDLxk1UGW/MTzAWE45iNoNA8Yy1tbmrh36sxkL3Gz/PdOhoPrqJ4AAnp5nHArAWV1H0OMA5JDV5Y4IRsTC9d8+guF+ZTZJ8owP2F+9ZtFsFAp8i7Jirh3SoC9EYLTbIKaozSiUZnj4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609969121; 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=a3Fe0NdSmaEMIlLXaYRLeZTKW2qWkhFhNQ9pMp+4jN0=; b=CoR49RqF6jGSg8eEy7LQ+vzt/LozMiOpOEDX0jVPFpT79++ScA8CXYgxkqvhMndM3h3V0cQmdPzI6XoBHfibYXYVyOq033XWpBUlhfKjvi6RiADe8WQcFylmm6ZUI1/Pn1tPOTZkhj0h2OYNV3kOTAQXnrfzYnL2L6sFXot+JpA= 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 1609969121550934.8238887166713; Wed, 6 Jan 2021 13:38:41 -0800 (PST) Received: from localhost ([::1]:35564 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGVs-0005OF-5N for importer@patchew.org; Wed, 06 Jan 2021 16:38:40 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57772) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMZ-0002wX-Fx for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:03 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:22506) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMW-0001lc-B3 for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:03 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id B5DAD7475F6; Wed, 6 Jan 2021 22:28:58 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 21CC57470E0; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: <787c2b74a286520e588914a6d584595c62c457f7.1609967638.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 03/12] vt82c686: Fix SMBus IO base and configuration registers Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The base address of the SMBus io ports and its enabled status is set by registers in the PCI config space but this was not correctly emulated. Instead the SMBus registers were mapped on realize to the base address set by a property to the address expected by fuloong2e firmware. Fix the base and config register handling to more closely model hardware which allows to remove the property and allows the guest to control this mapping. Do all this in reset instead of realize so it's correctly updated on reset. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 49 +++++++++++++++++++++++++++++++++------------ hw/mips/fuloong2e.c | 4 +--- 2 files changed, 37 insertions(+), 16 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index fe8961b057..9c4d153022 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -22,6 +22,7 @@ #include "hw/i2c/pm_smbus.h" #include "qapi/error.h" #include "qemu/module.h" +#include "qemu/range.h" #include "qemu/timer.h" #include "exec/address-spaces.h" #include "trace.h" @@ -34,7 +35,6 @@ struct VT686PMState { ACPIREGS ar; APMState apm; PMSMBus smb; - uint32_t smb_io_base; }; =20 static void pm_io_space_update(VT686PMState *s) @@ -50,11 +50,22 @@ static void pm_io_space_update(VT686PMState *s) memory_region_transaction_commit(); } =20 +static void smb_io_space_update(VT686PMState *s) +{ + uint32_t smbase =3D pci_get_long(s->dev.config + 0x90) & 0xfff0UL; + + memory_region_transaction_begin(); + memory_region_set_address(&s->smb.io, smbase); + memory_region_set_enabled(&s->smb.io, s->dev.config[0xd2] & BIT(0)); + memory_region_transaction_commit(); +} + static int vmstate_acpi_post_load(void *opaque, int version_id) { VT686PMState *s =3D opaque; =20 pm_io_space_update(s); + smb_io_space_update(s); return 0; } =20 @@ -77,8 +88,18 @@ static const VMStateDescription vmstate_acpi =3D { =20 static void pm_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int= len) { + VT686PMState *s =3D VT82C686B_PM(d); + trace_via_pm_write(addr, val, len); pci_default_write_config(d, addr, val, len); + if (ranges_overlap(addr, len, 0x90, 4)) { + uint32_t v =3D pci_get_long(s->dev.config + 0x90); + pci_set_long(s->dev.config + 0x90, (v & 0xfff0UL) | 1); + } + if (range_covers_byte(addr, len, 0xd2)) { + s->dev.config[0xd2] &=3D 0xf; + smb_io_space_update(s); + } } =20 static void pm_update_sci(VT686PMState *s) @@ -103,6 +124,17 @@ static void pm_tmr_timer(ACPIREGS *ar) pm_update_sci(s); } =20 +static void vt82c686b_pm_reset(DeviceState *d) +{ + VT686PMState *s =3D VT82C686B_PM(d); + + /* SMBus IO base */ + pci_set_long(s->dev.config + 0x90, 1); + s->dev.config[0xd2] =3D 0; + + smb_io_space_update(s); +} + static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) { VT686PMState *s =3D VT82C686B_PM(dev); @@ -116,13 +148,9 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error= **errp) /* 0x48-0x4B is Power Management I/O Base */ pci_set_long(pci_conf + 0x48, 0x00000001); =20 - /* SMB ports:0xeee0~0xeeef */ - s->smb_io_base =3D ((s->smb_io_base & 0xfff0) + 0x0); - pci_conf[0x90] =3D s->smb_io_base | 1; - pci_conf[0x91] =3D s->smb_io_base >> 8; - pci_conf[0xd2] =3D 0x90; pm_smbus_init(DEVICE(s), &s->smb, false); - memory_region_add_subregion(get_system_io(), s->smb_io_base, &s->smb.i= o); + memory_region_add_subregion(pci_address_space_io(dev), 0, &s->smb.io); + memory_region_set_enabled(&s->smb.io, false); =20 apm_init(dev, &s->apm, NULL, s); =20 @@ -135,11 +163,6 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error= **errp) acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2); } =20 -static Property via_pm_properties[] =3D { - DEFINE_PROP_UINT32("smb_io_base", VT686PMState, smb_io_base, 0), - DEFINE_PROP_END_OF_LIST(), -}; - static void via_pm_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); @@ -151,10 +174,10 @@ static void via_pm_class_init(ObjectClass *klass, voi= d *data) k->device_id =3D PCI_DEVICE_ID_VIA_ACPI; k->class_id =3D PCI_CLASS_BRIDGE_OTHER; k->revision =3D 0x40; + dc->reset =3D vt82c686b_pm_reset; dc->desc =3D "PM"; dc->vmsd =3D &vmstate_acpi; set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); - device_class_set_props(dc, via_pm_properties); } =20 static const TypeInfo via_pm_info =3D { diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index 29805242ca..fbdd6122b3 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -251,9 +251,7 @@ static void vt82c686b_southbridge_init(PCIBus *pci_bus,= int slot, qemu_irq intc, pci_create_simple(pci_bus, PCI_DEVFN(slot, 2), "vt82c686b-usb-uhci"); pci_create_simple(pci_bus, PCI_DEVFN(slot, 3), "vt82c686b-usb-uhci"); =20 - dev =3D pci_new(PCI_DEVFN(slot, 4), TYPE_VT82C686B_PM); - qdev_prop_set_uint32(DEVICE(dev), "smb_io_base", 0xeee1); - pci_realize_and_unref(dev, pci_bus, &error_fatal); + dev =3D pci_create_simple(pci_bus, PCI_DEVFN(slot, 4), TYPE_VT82C686B_= PM); *i2c_bus =3D I2C_BUS(qdev_get_child_bus(DEVICE(dev), "i2c")); =20 /* Audio support */ --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609968795; cv=none; d=zohomail.com; s=zohoarc; b=MrDdjB+lP3wIaCnwnquBg3OZJ384A7/2/1D9GeQpXTXehdMJrfhDyhaHmPgh45iqu84hhYNoVY8oWgTC4v96v1XULxjHWelkUr/W7QQp8oqtaiD6OTLskjDOcj/LBs9fQ9vu9fVuPvS1XzWsRIh9o8me+bY9ku4BqajWvZEDq/U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609968795; 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=uNu8OXLNePiQ8Sw00IA5D8oFwG7hZWujyS1q7C4qDMo=; b=JhLC2RTZ3IInk+8ifI73hBW/fNwmU7lvSf7obCyYeusClTafcdLoaqXVS3quglF8lxS2w29fIVqkmPGZAmwQZ4cSKkRL1LvkNuF8g0GZ6H/U/zMVuO2tm0dTG8tn2ukyYKAkPvZCM9WXzFfJ23oV4MUCTTQlUwxusTYRhCl/xXs= 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 1609968795703876.9831668933357; Wed, 6 Jan 2021 13:33:15 -0800 (PST) Received: from localhost ([::1]:50444 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGQc-0007pC-Ka for importer@patchew.org; Wed, 06 Jan 2021 16:33:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57658) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMU-0002pU-6p for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:28:58 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:22462) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMP-0001jL-SC for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:28:57 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 7F8387470F5; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 26D1A7470F6; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 04/12] vt82c686: Fix up power management io base and config Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Similar to the SMBus io registers there is a power management io range that is set via similar base address reg and enable bit. Some handling of this was already there but with several problems: using the wrong registers and bits, wrong size range, not acually updating mapping and handling reset correctly, nor emulating any of the actual io registers. Some of these errors are fixed up here. After this patch we use the correct base address register, enable bit and region size and allow guests to map/unmap this region and correctly reset all registers to default values on reset but we still don't emulate any of the registers in this range. Previously just an empty RAM region was mapped on realize, now we add an empty io range logging access instead. I think the pm timer should be hooked up here but not sure guests need it. PMON on fuloong2e sets a base address but does not seem to enable region; the pegasos2 firmware pokes some regs but continues anyway so don't know if anything would make use of these facilities. Therefore this is just a clean up of previous state for now and not intending to fully implement missing functionality which could be done later if some guests need it. Signed-off-by: BALATON Zoltan --- hw/isa/trace-events | 2 ++ hw/isa/vt82c686.c | 56 ++++++++++++++++++++++++++++++++------------- 2 files changed, 42 insertions(+), 16 deletions(-) diff --git a/hw/isa/trace-events b/hw/isa/trace-events index d267d3e652..641d69eedf 100644 --- a/hw/isa/trace-events +++ b/hw/isa/trace-events @@ -17,5 +17,7 @@ apm_io_write(uint8_t addr, uint8_t val) "write addr=3D0x%= x val=3D0x%02x" # vt82c686.c via_isa_write(uint32_t addr, uint32_t val, int len) "addr 0x%x val 0x%x le= n 0x%x" via_pm_write(uint32_t addr, uint32_t val, int len) "addr 0x%x val 0x%x len= 0x%x" +via_pm_io_read(uint32_t addr, uint32_t val, int len) "addr 0x%x val 0x%x l= en 0x%x" +via_pm_io_write(uint32_t addr, uint32_t val, int len) "addr 0x%x val 0x%x = len 0x%x" via_superio_read(uint8_t addr, uint8_t val) "addr 0x%x val 0x%x" via_superio_write(uint8_t addr, uint32_t val) "addr 0x%x val 0x%x" diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 9c4d153022..fc2a1f4430 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -39,14 +39,11 @@ struct VT686PMState { =20 static void pm_io_space_update(VT686PMState *s) { - uint32_t pm_io_base; - - pm_io_base =3D pci_get_long(s->dev.config + 0x40); - pm_io_base &=3D 0xffc0; + uint32_t pmbase =3D pci_get_long(s->dev.config + 0x48) & 0xff80UL; =20 memory_region_transaction_begin(); - memory_region_set_enabled(&s->io, s->dev.config[0x80] & 1); - memory_region_set_address(&s->io, pm_io_base); + memory_region_set_address(&s->io, pmbase); + memory_region_set_enabled(&s->io, s->dev.config[0x41] & BIT(7)); memory_region_transaction_commit(); } =20 @@ -92,6 +89,13 @@ static void pm_write_config(PCIDevice *d, uint32_t addr,= uint32_t val, int len) =20 trace_via_pm_write(addr, val, len); pci_default_write_config(d, addr, val, len); + if (ranges_overlap(addr, len, 0x48, 4)) { + uint32_t v =3D pci_get_long(s->dev.config + 0x48); + pci_set_long(s->dev.config + 0x48, (v & 0xff80UL) | 1); + } + if (range_covers_byte(addr, len, 0x41)) { + pm_io_space_update(s); + } if (ranges_overlap(addr, len, 0x90, 4)) { uint32_t v =3D pci_get_long(s->dev.config + 0x90); pci_set_long(s->dev.config + 0x90, (v & 0xfff0UL) | 1); @@ -102,6 +106,27 @@ static void pm_write_config(PCIDevice *d, uint32_t add= r, uint32_t val, int len) } } =20 +static void pm_io_write(void *op, hwaddr addr, uint64_t data, unsigned siz= e) +{ + trace_via_pm_io_write(addr, data, size); +} + +static uint64_t pm_io_read(void *op, hwaddr addr, unsigned size) +{ + trace_via_pm_io_read(addr, 0, size); + return 0; +} + +static const MemoryRegionOps pm_io_ops =3D { + .read =3D pm_io_read, + .write =3D pm_io_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; + static void pm_update_sci(VT686PMState *s) { int sci_level, pmsts; @@ -128,35 +153,34 @@ static void vt82c686b_pm_reset(DeviceState *d) { VT686PMState *s =3D VT82C686B_PM(d); =20 + memset(s->dev.config + PCI_CONFIG_HEADER_SIZE, 0, + PCI_CONFIG_SPACE_SIZE - PCI_CONFIG_HEADER_SIZE); + /* Power Management IO base */ + pci_set_long(s->dev.config + 0x48, 1); /* SMBus IO base */ pci_set_long(s->dev.config + 0x90, 1); - s->dev.config[0xd2] =3D 0; =20 + pm_io_space_update(s); smb_io_space_update(s); } =20 static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) { VT686PMState *s =3D VT82C686B_PM(dev); - uint8_t *pci_conf; =20 - pci_conf =3D s->dev.config; - pci_set_word(pci_conf + PCI_COMMAND, 0); - pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_FAST_BACK | + pci_set_word(dev->config + PCI_STATUS, PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM); =20 - /* 0x48-0x4B is Power Management I/O Base */ - pci_set_long(pci_conf + 0x48, 0x00000001); - pm_smbus_init(DEVICE(s), &s->smb, false); memory_region_add_subregion(pci_address_space_io(dev), 0, &s->smb.io); memory_region_set_enabled(&s->smb.io, false); =20 apm_init(dev, &s->apm, NULL, s); =20 - memory_region_init(&s->io, OBJECT(dev), "vt82c686-pm", 64); + memory_region_init_io(&s->io, OBJECT(dev), &pm_io_ops, s, + "vt82c686-pm", 0x100); + memory_region_add_subregion(pci_address_space_io(dev), 0, &s->io); memory_region_set_enabled(&s->io, false); - memory_region_add_subregion(get_system_io(), 0, &s->io); =20 acpi_pm_tmr_init(&s->ar, pm_tmr_timer, &s->io); acpi_pm1_evt_init(&s->ar, pm_tmr_timer, &s->io); --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609968599; cv=none; d=zohomail.com; s=zohoarc; b=CU2PhRoIQ8sDXHFdLoVD07lSSEqPG9oSRFZhqwITJNEcjULie0kVzfQV1RLgWMtjqKa+CtkMVJ/pV6Qcn5VpOivSpd59T9+Ns7pczJ1oBpko/jxIdcomVbxp4Syzd/LpWuIxT8cwVTCGHgGtnz8paPV7l4I8dYloOd5NitGNX44= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609968599; 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=mrolqmzRPOEtgfkzRVcYVPhL/oP/f3ebqNPA3IGTbd4=; b=hP4eu52k+xA8g6woGtiSppQOzFkYvL5gR2x0pHiqOCy5AN3PWGDgFKyMuXEbnwBQ6SdUPdTbyzL1VJbfIXAHM96/1PB9Oz0ny2yTb135Yl8h1hsbz7dT+B8tPZ0ST0Z6U/OHRuomI+GNFt6CboZWIBdHqC+FFdO8SToabIJJRbM= 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 1609968599592432.2712122091151; Wed, 6 Jan 2021 13:29:59 -0800 (PST) Received: from localhost ([::1]:42852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGNS-0004Sb-GG for importer@patchew.org; Wed, 06 Jan 2021 16:29:58 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57654) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMT-0002pM-Vk for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:28:58 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:22467) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMP-0001jN-S5 for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:28:57 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 95BB07470FF; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 2C6CA7470F4; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 05/12] vt82c686: Make vt82c686b-pm an abstract base class and add vt8231-pm based on it Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The vt82c686b-pm model can be shared between VT82C686B and VT8231. The only difference between the two is the device id in what we emulate so make an abstract via-pm model by renaming appropriately and add types for vt82c686b-pm and vt8231-pm based on it. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 87 ++++++++++++++++++++++++++------------- include/hw/isa/vt82c686.h | 1 + 2 files changed, 59 insertions(+), 29 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index fc2a1f4430..a989e29fe5 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -27,9 +27,10 @@ #include "exec/address-spaces.h" #include "trace.h" =20 -OBJECT_DECLARE_SIMPLE_TYPE(VT686PMState, VT82C686B_PM) +#define TYPE_VIA_PM "via-pm" +OBJECT_DECLARE_SIMPLE_TYPE(ViaPMState, VIA_PM) =20 -struct VT686PMState { +struct ViaPMState { PCIDevice dev; MemoryRegion io; ACPIREGS ar; @@ -37,7 +38,7 @@ struct VT686PMState { PMSMBus smb; }; =20 -static void pm_io_space_update(VT686PMState *s) +static void pm_io_space_update(ViaPMState *s) { uint32_t pmbase =3D pci_get_long(s->dev.config + 0x48) & 0xff80UL; =20 @@ -47,7 +48,7 @@ static void pm_io_space_update(VT686PMState *s) memory_region_transaction_commit(); } =20 -static void smb_io_space_update(VT686PMState *s) +static void smb_io_space_update(ViaPMState *s) { uint32_t smbase =3D pci_get_long(s->dev.config + 0x90) & 0xfff0UL; =20 @@ -59,7 +60,7 @@ static void smb_io_space_update(VT686PMState *s) =20 static int vmstate_acpi_post_load(void *opaque, int version_id) { - VT686PMState *s =3D opaque; + ViaPMState *s =3D opaque; =20 pm_io_space_update(s); smb_io_space_update(s); @@ -72,20 +73,20 @@ static const VMStateDescription vmstate_acpi =3D { .minimum_version_id =3D 1, .post_load =3D vmstate_acpi_post_load, .fields =3D (VMStateField[]) { - VMSTATE_PCI_DEVICE(dev, VT686PMState), - VMSTATE_UINT16(ar.pm1.evt.sts, VT686PMState), - VMSTATE_UINT16(ar.pm1.evt.en, VT686PMState), - VMSTATE_UINT16(ar.pm1.cnt.cnt, VT686PMState), - VMSTATE_STRUCT(apm, VT686PMState, 0, vmstate_apm, APMState), - VMSTATE_TIMER_PTR(ar.tmr.timer, VT686PMState), - VMSTATE_INT64(ar.tmr.overflow_time, VT686PMState), + VMSTATE_PCI_DEVICE(dev, ViaPMState), + VMSTATE_UINT16(ar.pm1.evt.sts, ViaPMState), + VMSTATE_UINT16(ar.pm1.evt.en, ViaPMState), + VMSTATE_UINT16(ar.pm1.cnt.cnt, ViaPMState), + VMSTATE_STRUCT(apm, ViaPMState, 0, vmstate_apm, APMState), + VMSTATE_TIMER_PTR(ar.tmr.timer, ViaPMState), + VMSTATE_INT64(ar.tmr.overflow_time, ViaPMState), VMSTATE_END_OF_LIST() } }; =20 static void pm_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int= len) { - VT686PMState *s =3D VT82C686B_PM(d); + ViaPMState *s =3D VIA_PM(d); =20 trace_via_pm_write(addr, val, len); pci_default_write_config(d, addr, val, len); @@ -127,7 +128,7 @@ static const MemoryRegionOps pm_io_ops =3D { }, }; =20 -static void pm_update_sci(VT686PMState *s) +static void pm_update_sci(ViaPMState *s) { int sci_level, pmsts; =20 @@ -145,13 +146,13 @@ static void pm_update_sci(VT686PMState *s) =20 static void pm_tmr_timer(ACPIREGS *ar) { - VT686PMState *s =3D container_of(ar, VT686PMState, ar); + ViaPMState *s =3D container_of(ar, ViaPMState, ar); pm_update_sci(s); } =20 -static void vt82c686b_pm_reset(DeviceState *d) +static void via_pm_reset(DeviceState *d) { - VT686PMState *s =3D VT82C686B_PM(d); + ViaPMState *s =3D VIA_PM(d); =20 memset(s->dev.config + PCI_CONFIG_HEADER_SIZE, 0, PCI_CONFIG_SPACE_SIZE - PCI_CONFIG_HEADER_SIZE); @@ -164,9 +165,9 @@ static void vt82c686b_pm_reset(DeviceState *d) smb_io_space_update(s); } =20 -static void vt82c686b_pm_realize(PCIDevice *dev, Error **errp) +static void via_pm_realize(PCIDevice *dev, Error **errp) { - VT686PMState *s =3D VT82C686B_PM(dev); + ViaPMState *s =3D VIA_PM(dev); =20 pci_set_word(dev->config + PCI_STATUS, PCI_STATUS_FAST_BACK | PCI_STATUS_DEVSEL_MEDIUM); @@ -177,8 +178,7 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Error = **errp) =20 apm_init(dev, &s->apm, NULL, s); =20 - memory_region_init_io(&s->io, OBJECT(dev), &pm_io_ops, s, - "vt82c686-pm", 0x100); + memory_region_init_io(&s->io, OBJECT(dev), &pm_io_ops, s, "via-pm", 0x= 100); memory_region_add_subregion(pci_address_space_io(dev), 0, &s->io); memory_region_set_enabled(&s->io, false); =20 @@ -187,34 +187,61 @@ static void vt82c686b_pm_realize(PCIDevice *dev, Erro= r **errp) acpi_pm1_cnt_init(&s->ar, &s->io, false, false, 2); } =20 +typedef struct via_pm_init_info { + uint16_t device_id; +} ViaPMInitInfo; + static void via_pm_class_init(ObjectClass *klass, void *data) { DeviceClass *dc =3D DEVICE_CLASS(klass); PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + ViaPMInitInfo *info =3D data; =20 - k->realize =3D vt82c686b_pm_realize; + k->realize =3D via_pm_realize; k->config_write =3D pm_write_config; k->vendor_id =3D PCI_VENDOR_ID_VIA; - k->device_id =3D PCI_DEVICE_ID_VIA_ACPI; + k->device_id =3D info->device_id; k->class_id =3D PCI_CLASS_BRIDGE_OTHER; k->revision =3D 0x40; - dc->reset =3D vt82c686b_pm_reset; - dc->desc =3D "PM"; + dc->reset =3D via_pm_reset; + /* Reason: part of VIA south bridge, does not exist stand alone */ + dc->user_creatable =3D false; dc->vmsd =3D &vmstate_acpi; - set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories); } =20 static const TypeInfo via_pm_info =3D { - .name =3D TYPE_VT82C686B_PM, + .name =3D TYPE_VIA_PM, .parent =3D TYPE_PCI_DEVICE, - .instance_size =3D sizeof(VT686PMState), - .class_init =3D via_pm_class_init, + .instance_size =3D sizeof(ViaPMState), + .abstract =3D true, .interfaces =3D (InterfaceInfo[]) { { INTERFACE_CONVENTIONAL_PCI_DEVICE }, { }, }, }; =20 +static const ViaPMInitInfo vt82c686b_pm_init_info =3D { + .device_id =3D PCI_DEVICE_ID_VIA_ACPI, +}; + +static const TypeInfo vt82c686b_pm_info =3D { + .name =3D TYPE_VT82C686B_PM, + .parent =3D TYPE_VIA_PM, + .class_init =3D via_pm_class_init, + .class_data =3D (void *)&vt82c686b_pm_init_info, +}; + +static const ViaPMInitInfo vt8231_pm_init_info =3D { + .device_id =3D 0x8235, +}; + +static const TypeInfo vt8231_pm_info =3D { + .name =3D TYPE_VT8231_PM, + .parent =3D TYPE_VIA_PM, + .class_init =3D via_pm_class_init, + .class_data =3D (void *)&vt8231_pm_init_info, +}; + =20 typedef struct SuperIOConfig { uint8_t regs[0x100]; @@ -423,6 +450,8 @@ static const TypeInfo via_superio_info =3D { static void vt82c686b_register_types(void) { type_register_static(&via_pm_info); + type_register_static(&vt82c686b_pm_info); + type_register_static(&vt8231_pm_info); type_register_static(&via_info); type_register_static(&via_superio_info); } diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h index 5b0a1ffe72..9b6d610e83 100644 --- a/include/hw/isa/vt82c686.h +++ b/include/hw/isa/vt82c686.h @@ -4,6 +4,7 @@ #define TYPE_VT82C686B_ISA "vt82c686b-isa" #define TYPE_VT82C686B_SUPERIO "vt82c686b-superio" #define TYPE_VT82C686B_PM "vt82c686b-pm" +#define TYPE_VT8231_PM "vt8231-pm" #define TYPE_VIA_AC97 "via-ac97" #define TYPE_VIA_MC97 "via-mc97" =20 --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609968795; cv=none; d=zohomail.com; s=zohoarc; b=UMl/EKiMx+9sNJ1yFtz5CXOqAUXdxaQupmpP5/hP5hENKUfRjhLsJtMp1Zyt9yP7DEzT/v5V1N9YIJuCxFzQfriNJwjoGVVbybqvwbZpP+rOVkCuaQ9q2/05OISapNU/JEdiIS5HRgYqSE+PQl0r5e9nhmzqde21gr49+p9YFtk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609968795; 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=J1q9ZzVGiJZ0jeoTwYkA42SLZ27S1TCohi/k90ksUGo=; b=EPapzs9jCHz5RKMQvVTCmvhX00pa/tH4p33G5y2pXe3reGYpU5AZvbyjm05dNVEdY03M++WuK1SbDscvEAGeTc3IVGaLDvPApbAowpyj+ywkhExeZmahWNybihFcqIOgM869jX6WSzi/zqwCMESQ6oIvGM+n/cgGz5ADsyLjDJs= 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 16099687950274.2404211167252015; Wed, 6 Jan 2021 13:33:15 -0800 (PST) Received: from localhost ([::1]:50320 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGQb-0007lt-TA for importer@patchew.org; Wed, 06 Jan 2021 16:33:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57636) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMT-0002os-AP for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:28:57 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:22469) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMP-0001jO-S1 for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:28:57 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id A8AE27470F6; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 333DE7470F7; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 06/12] vt82c686: Simplify vt82c686b_realize() Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Remove unneeded variables and setting value to 0 on zero initialised data and replace check for error with error_fatal. Rationalise loop that sets PCI config header fields read only. Signed-off-by: BALATON Zoltan Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/isa/vt82c686.c | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index a989e29fe5..ead60310fe 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -363,24 +363,16 @@ static void vt82c686b_isa_reset(DeviceState *dev) static void vt82c686b_realize(PCIDevice *d, Error **errp) { VT82C686BISAState *s =3D VT82C686B_ISA(d); - uint8_t *pci_conf; + DeviceState *dev =3D DEVICE(d); ISABus *isa_bus; - uint8_t *wmask; int i; =20 - isa_bus =3D isa_bus_new(DEVICE(d), get_system_memory(), - pci_address_space_io(d), errp); - if (!isa_bus) { - return; - } - - pci_conf =3D d->config; - pci_config_set_prog_interface(pci_conf, 0x0); + isa_bus =3D isa_bus_new(dev, get_system_memory(), pci_address_space_io= (d), + &error_fatal); =20 - wmask =3D d->wmask; - for (i =3D 0x00; i < 0xff; i++) { - if (i <=3D 0x03 || (i >=3D 0x08 && i <=3D 0x3f)) { - wmask[i] =3D 0x00; + for (i =3D 0; i < PCI_CONFIG_HEADER_SIZE; i++) { + if (i < PCI_COMMAND || i >=3D PCI_REVISION_ID) { + d->wmask[i] =3D 0; } } =20 --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609968919; cv=none; d=zohomail.com; s=zohoarc; b=b5nT/OAKZ4Lk8daYQSn3H3OFXImKS+5vYaSY7HA63OEmuCMsQVLmuHmHM/KTqcK12nbwosLTpY3dqrnvchJQ+VZZMdfxhnj9Aa1W4qxg3aYTfux8rzrW3+Bm/U0cJyKgE7AKV/W/ZZgjXed2Vxya+ve38nrMJjq/hZx2KjDE52A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609968919; 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=IEQyeJc1ilZJxln0pfeltA44xUYBG4rE+PeMEgeT1pU=; b=F6CPrJrBN4oX1NSMpXfeKaa6HrVm3z/t9JxyH5rMzC6spkswmrOfDAel23gtaZOpNL4zDF0ztPIX6N4t+BRDKq14zU68EBP7gkIK4TF66NBl2QMdpxyf0hal83c9yQvgqrxWuKkROxa6KFkPtmiT+zpag3KkuDzsnjPTQ3hJF3k= 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 1609968919534958.7688043948106; Wed, 6 Jan 2021 13:35:19 -0800 (PST) Received: from localhost ([::1]:55024 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGSc-0001iN-Fg for importer@patchew.org; Wed, 06 Jan 2021 16:35:18 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57688) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMV-0002qT-V0 for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:00 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:22495) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMT-0001ks-R8 for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:28:59 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id CAD1F7470F4; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 37DAB7470F8; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: <057fa3b929d3436670ab8925cee51815653626d0.1609967638.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 07/12] vt82c686: Move creation of ISA devices to the ISA bridge Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Currently the ISA devices that are part of the VIA south bridge, superio chip are wired up by board code. Move creation of these ISA devices to the VIA ISA bridge model so that board code does not need to access ISA bus. This also allows vt82c686b-superio to be made internal to vt82c686 which allows implementing its configuration via registers in subseqent commits. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 20 ++++++++++++++++++++ hw/mips/fuloong2e.c | 29 +++++------------------------ 2 files changed, 25 insertions(+), 24 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index ead60310fe..3a45056226 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -16,6 +16,11 @@ #include "hw/qdev-properties.h" #include "hw/isa/isa.h" #include "hw/isa/superio.h" +#include "hw/intc/i8259.h" +#include "hw/irq.h" +#include "hw/dma/i8257.h" +#include "hw/timer/i8254.h" +#include "hw/rtc/mc146818rtc.h" #include "migration/vmstate.h" #include "hw/isa/apm.h" #include "hw/acpi/acpi.h" @@ -307,9 +312,16 @@ OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686= B_ISA) =20 struct VT82C686BISAState { PCIDevice dev; + qemu_irq cpu_intr; SuperIOConfig superio_cfg; }; =20 +static void via_isa_request_i8259_irq(void *opaque, int irq, int level) +{ + VT82C686BISAState *s =3D opaque; + qemu_set_irq(s->cpu_intr, level); +} + static void vt82c686b_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len) { @@ -365,10 +377,18 @@ static void vt82c686b_realize(PCIDevice *d, Error **e= rrp) VT82C686BISAState *s =3D VT82C686B_ISA(d); DeviceState *dev =3D DEVICE(d); ISABus *isa_bus; + qemu_irq *isa_irq; int i; =20 + qdev_init_gpio_out(dev, &s->cpu_intr, 1); + isa_irq =3D qemu_allocate_irqs(via_isa_request_i8259_irq, s, 1); isa_bus =3D isa_bus_new(dev, get_system_memory(), pci_address_space_io= (d), &error_fatal); + isa_bus_irqs(isa_bus, i8259_init(isa_bus, *isa_irq)); + i8254_pit_init(isa_bus, 0x40, 0, NULL); + i8257_dma_init(isa_bus, 0); + isa_create_simple(isa_bus, TYPE_VT82C686B_SUPERIO); + mc146818_rtc_init(isa_bus, 2000, NULL); =20 for (i =3D 0; i < PCI_CONFIG_HEADER_SIZE; i++) { if (i < PCI_COMMAND || i >=3D PCI_REVISION_ID) { diff --git a/hw/mips/fuloong2e.c b/hw/mips/fuloong2e.c index fbdd6122b3..0fc3288556 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -25,9 +25,6 @@ #include "qapi/error.h" #include "cpu.h" #include "hw/clock.h" -#include "hw/intc/i8259.h" -#include "hw/dma/i8257.h" -#include "hw/isa/superio.h" #include "net/net.h" #include "hw/boards.h" #include "hw/i2c/smbus_eeprom.h" @@ -38,13 +35,13 @@ #include "qemu/log.h" #include "hw/loader.h" #include "hw/ide/pci.h" +#include "hw/qdev-properties.h" #include "elf.h" #include "hw/isa/vt82c686.h" -#include "hw/rtc/mc146818rtc.h" -#include "hw/timer/i8254.h" #include "exec/address-spaces.h" #include "sysemu/qtest.h" #include "sysemu/reset.h" +#include "sysemu/sysemu.h" #include "qemu/error-report.h" =20 #define ENVP_PADDR 0x2000 @@ -224,26 +221,13 @@ static void main_cpu_reset(void *opaque) } =20 static void vt82c686b_southbridge_init(PCIBus *pci_bus, int slot, qemu_irq= intc, - I2CBus **i2c_bus, ISABus **p_isa_bu= s) + I2CBus **i2c_bus) { - qemu_irq *i8259; - ISABus *isa_bus; PCIDevice *dev; =20 dev =3D pci_create_simple_multifunction(pci_bus, PCI_DEVFN(slot, 0), t= rue, TYPE_VT82C686B_ISA); - isa_bus =3D ISA_BUS(qdev_get_child_bus(DEVICE(dev), "isa.0")); - assert(isa_bus); - *p_isa_bus =3D isa_bus; - /* Interrupt controller */ - /* The 8259 -> IP5 */ - i8259 =3D i8259_init(isa_bus, intc); - isa_bus_irqs(isa_bus, i8259); - /* init other devices */ - i8254_pit_init(isa_bus, 0x40, 0, NULL); - i8257_dma_init(isa_bus, 0); - /* Super I/O */ - isa_create_simple(isa_bus, TYPE_VT82C686B_SUPERIO); + qdev_connect_gpio_out(DEVICE(dev), 0, intc); =20 dev =3D pci_create_simple(pci_bus, PCI_DEVFN(slot, 1), "via-ide"); pci_ide_create_devs(dev); @@ -290,7 +274,6 @@ static void mips_fuloong2e_init(MachineState *machine) uint64_t kernel_entry; PCIDevice *pci_dev; PCIBus *pci_bus; - ISABus *isa_bus; I2CBus *smbus; Clock *cpuclk; MIPSCPU *cpu; @@ -357,7 +340,7 @@ static void mips_fuloong2e_init(MachineState *machine) =20 /* South bridge -> IP5 */ vt82c686b_southbridge_init(pci_bus, FULOONG2E_VIA_SLOT, env->irq[5], - &smbus, &isa_bus); + &smbus); =20 /* GPU */ if (vga_interface_type !=3D VGA_NONE) { @@ -372,8 +355,6 @@ static void mips_fuloong2e_init(MachineState *machine) spd_data =3D spd_data_generate(DDR, machine->ram_size); smbus_eeprom_init_one(smbus, 0x50, spd_data); =20 - mc146818_rtc_init(isa_bus, 2000, NULL); - /* Network card: RTL8139D */ network_init(pci_bus); } --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609969317; cv=none; d=zohomail.com; s=zohoarc; b=cTfe+KD6pRAE5FexIOY4iTgyKM4WaMYxMThy5Fau0kgrnwCYwVKSCARGeacSl0Ikbv03li81C8+wd4Sj7wcvG0Jg2q+lWjOBnSnrGQyl33TzEhuuJE7RCsl3SMqs+RSC1Wy7tucsLE5S3l5u0tSHeR05vF0ctw0Dj6Z7gWs6+lU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609969317; 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=ok1O6U92LA6s9I78l79cmiPiAFjO4I/nJ/GA0dA1Lsc=; b=oBwoil70YEEOIoRU4kGmbcYLxKMhBHK9rzNBPUnR9PS126on5g1snPHY2UbtFjzV9uCjn2h+4Io2AmEgBs81x1auy1If1ATu/9QXTCl2uzbVemO0Kc/oZBSsMjiSHQGACgq/s378pbbmjtgac8tDAl8c0hs22UbaH16zl0oWfTc= 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 1609969317394498.7825198502252; Wed, 6 Jan 2021 13:41:57 -0800 (PST) Received: from localhost ([::1]:39978 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGZ2-0007UW-9d for importer@patchew.org; Wed, 06 Jan 2021 16:41:56 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57790) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMa-0002xp-1E for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:04 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:22496) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMT-0001kt-4A for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:03 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id D7F267470F7; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 3CC057470F9; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 08/12] vt82c686: Fix superio_cfg_{read,write}() functions Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" These functions are memory region callbacks so we have to check against relative address not the mapped address. Also reduce indentation by returning early and log unimplemented accesses. Additionally we remove separate index value from SuperIOConfig and store the index at reg 0 which is reserved and returns 0 on read. This simpilifies object state. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 63 ++++++++++++++++++++++++++--------------------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 3a45056226..1a876a1fbf 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -26,6 +26,7 @@ #include "hw/acpi/acpi.h" #include "hw/i2c/pm_smbus.h" #include "qapi/error.h" +#include "qemu/log.h" #include "qemu/module.h" #include "qemu/range.h" #include "qemu/timer.h" @@ -250,7 +251,6 @@ static const TypeInfo vt8231_pm_info =3D { =20 typedef struct SuperIOConfig { uint8_t regs[0x100]; - uint8_t index; MemoryRegion io; } SuperIOConfig; =20 @@ -258,42 +258,49 @@ static void superio_cfg_write(void *opaque, hwaddr ad= dr, uint64_t data, unsigned size) { SuperIOConfig *sc =3D opaque; + uint8_t idx =3D sc->regs[0]; =20 - if (addr =3D=3D 0x3f0) { /* config index register */ - sc->index =3D data & 0xff; - } else { - bool can_write =3D true; - /* 0x3f1, config data register */ - trace_via_superio_write(sc->index, data & 0xff); - switch (sc->index) { - case 0x00 ... 0xdf: - case 0xe4: - case 0xe5: - case 0xe9 ... 0xed: - case 0xf3: - case 0xf5: - case 0xf7: - case 0xf9 ... 0xfb: - case 0xfd ... 0xff: - can_write =3D false; - break; - /* case 0xe6 ... 0xe8: Should set base port of parallel and serial= */ - default: - break; + if (addr =3D=3D 0) { /* config index register */ + sc->regs[0] =3D data; + return; + } =20 - } - if (can_write) { - sc->regs[sc->index] =3D data & 0xff; - } + /* config data register */ + trace_via_superio_write(idx, data); + switch (idx) { + case 0x00 ... 0xdf: + case 0xe4: + case 0xe5: + case 0xe9 ... 0xed: + case 0xf3: + case 0xf5: + case 0xf7: + case 0xf9 ... 0xfb: + case 0xfd ... 0xff: + /* ignore write to read only registers */ + return; + /* case 0xe6 ... 0xe8: Should set base port of parallel and serial */ + default: + qemu_log_mask(LOG_UNIMP, + "via_superio_cfg: unimplemented register 0x%x\n", id= x); + break; } + sc->regs[idx] =3D data; } =20 static uint64_t superio_cfg_read(void *opaque, hwaddr addr, unsigned size) { SuperIOConfig *sc =3D opaque; - uint8_t val =3D sc->regs[sc->index]; + uint8_t idx =3D sc->regs[0]; + uint8_t val =3D sc->regs[idx]; =20 - trace_via_superio_read(sc->index, val); + if (addr =3D=3D 0) { + return idx; + } + if (addr =3D=3D 1 && idx =3D=3D 0) { + val =3D 0; /* reading reg 0 where we store index value */ + } + trace_via_superio_read(idx, val); return val; } =20 --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609969029; cv=none; d=zohomail.com; s=zohoarc; b=CDWj4lHpJZCepJXAvPX8qlk1Gbifkv0/ckE3PGdEazMijH3rJj9bOLXLNb0sisd02Rj0WF8Nrb9C22sGYadPzRw+O61/BFoLpjrvgitvP+t87zKmRPRSvJk9QeZ43B/bnNeTaXhZmzNRHJ5J6lPI+KCdstAixC/kA47SGwBkvgQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609969029; 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=w8eRFA9pXTKv6O4hvSscpOs6i2piaXeA+ZVHp7dBkO8=; b=FbQyFypWMiCXOsCRMkM9PviLmsSQgWlUE+jQkwMVr9Ti26qL2XUA13+Qu1sKeTiOch75J0swOYXuNtjq90+AGPDZeNhM49udfZPSdJCcPdnxTEDmLPX/N0Wcc+41i9gbyHP2J1UeNp2H/b+gvh6aNbJcd9c53GlH0STnFnyuoIU= 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 1609969029004972.5409638801843; Wed, 6 Jan 2021 13:37:09 -0800 (PST) Received: from localhost ([::1]:59992 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGUN-0003r6-Rh for importer@patchew.org; Wed, 06 Jan 2021 16:37:07 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57732) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMX-0002rm-Ll for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:01 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:22498) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMV-0001l6-AH for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:01 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 0DF6D7470F8; Wed, 6 Jan 2021 22:28:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 40FF47470FB; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: <4699a79a989538458fc335d74a7bf52e8608e5e2.1609967638.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 09/12] vt82c686: Implement control of serial port io ranges via config regs Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" In VIA super south bridge the io ranges of superio components (parallel and serial ports and FDC) can be controlled by superio config registers to set their base address and enable/disable them. This is not easy to implement in QEMU because ISA emulation is only designed to set io base address once on creating the device and io ranges are registered at creation and cannot easily be disabled or moved later. In this patch we hack around that but only for serial ports because those have a single io range at port base that's relatively easy to handle and it's what guests actually use and set address different than the default. We do not attempt to handle controlling the parallel and FDC regions because those have multiple io ranges so handling them would be messy and guests either don't change their deafult or don't care. We could even get away with disabling and not emulating them, but since they are already there, this patch leaves them mapped at their default address just in case this could be useful for a guest in the future. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 84 +++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 82 insertions(+), 2 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 1a876a1fbf..26db1a18e2 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -252,8 +252,24 @@ static const TypeInfo vt8231_pm_info =3D { typedef struct SuperIOConfig { uint8_t regs[0x100]; MemoryRegion io; + ISASuperIODevice *superio; + MemoryRegion *serial_io[SUPERIO_MAX_SERIAL_PORTS]; } SuperIOConfig; =20 +static MemoryRegion *find_subregion(ISADevice *d, MemoryRegion *parent, + int offs) +{ + MemoryRegion *subregion, *mr =3D NULL; + + QTAILQ_FOREACH(subregion, &parent->subregions, subregions_link) { + if (subregion->addr =3D=3D offs) { + mr =3D subregion; + break; + } + } + return mr; +} + static void superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, unsigned size) { @@ -279,7 +295,53 @@ static void superio_cfg_write(void *opaque, hwaddr add= r, uint64_t data, case 0xfd ... 0xff: /* ignore write to read only registers */ return; - /* case 0xe6 ... 0xe8: Should set base port of parallel and serial */ + case 0xe2: + { + data &=3D 0x1f; + if (data & BIT(2)) { /* Serial port 1 enable */ + ISADevice *dev =3D sc->superio->serial[0]; + if (!memory_region_is_mapped(sc->serial_io[0])) { + memory_region_add_subregion(isa_address_space_io(dev), + dev->ioport_id, sc->serial_io[= 0]); + } + } else { + MemoryRegion *io =3D isa_address_space_io(sc->superio->serial[= 0]); + if (memory_region_is_mapped(sc->serial_io[0])) { + memory_region_del_subregion(io, sc->serial_io[0]); + } + } + if (data & BIT(3)) { /* Serial port 2 enable */ + ISADevice *dev =3D sc->superio->serial[1]; + if (!memory_region_is_mapped(sc->serial_io[1])) { + memory_region_add_subregion(isa_address_space_io(dev), + dev->ioport_id, sc->serial_io[= 1]); + } + } else { + MemoryRegion *io =3D isa_address_space_io(sc->superio->serial[= 1]); + if (memory_region_is_mapped(sc->serial_io[1])) { + memory_region_del_subregion(io, sc->serial_io[1]); + } + } + break; + } + case 0xe7: /* Serial port 1 io base address */ + { + data &=3D 0xfe; + sc->superio->serial[0]->ioport_id =3D data << 2; + if (memory_region_is_mapped(sc->serial_io[0])) { + memory_region_set_address(sc->serial_io[0], data << 2); + } + break; + } + case 0xe8: /* Serial port 2 io base address */ + { + data &=3D 0xfe; + sc->superio->serial[1]->ioport_id =3D data << 2; + if (memory_region_is_mapped(sc->serial_io[1])) { + memory_region_set_address(sc->serial_io[1], data << 2); + } + break; + } default: qemu_log_mask(LOG_UNIMP, "via_superio_cfg: unimplemented register 0x%x\n", id= x); @@ -385,6 +447,7 @@ static void vt82c686b_realize(PCIDevice *d, Error **err= p) DeviceState *dev =3D DEVICE(d); ISABus *isa_bus; qemu_irq *isa_irq; + ISASuperIOClass *ic; int i; =20 qdev_init_gpio_out(dev, &s->cpu_intr, 1); @@ -394,7 +457,9 @@ static void vt82c686b_realize(PCIDevice *d, Error **err= p) isa_bus_irqs(isa_bus, i8259_init(isa_bus, *isa_irq)); i8254_pit_init(isa_bus, 0x40, 0, NULL); i8257_dma_init(isa_bus, 0); - isa_create_simple(isa_bus, TYPE_VT82C686B_SUPERIO); + s->superio_cfg.superio =3D ISA_SUPERIO(isa_create_simple(isa_bus, + TYPE_VT82C686B_SUPER= IO)); + ic =3D ISA_SUPERIO_GET_CLASS(s->superio_cfg.superio); mc146818_rtc_init(isa_bus, 2000, NULL); =20 for (i =3D 0; i < PCI_CONFIG_HEADER_SIZE; i++) { @@ -412,6 +477,21 @@ static void vt82c686b_realize(PCIDevice *d, Error **er= rp) */ memory_region_add_subregion(isa_bus->address_space_io, 0x3f0, &s->superio_cfg.io); + + /* Grab io regions of serial devices so we can control them */ + for (i =3D 0; i < ic->serial.count; i++) { + ISADevice *sd =3D s->superio_cfg.superio->serial[i]; + MemoryRegion *io =3D isa_address_space_io(sd); + MemoryRegion *mr =3D find_subregion(sd, io, sd->ioport_id); + if (!mr) { + error_setg(errp, "Could not get io region for serial %d", i); + return; + } + s->superio_cfg.serial_io[i] =3D mr; + if (memory_region_is_mapped(mr)) { + memory_region_del_subregion(io, mr); + } + } } =20 static void via_class_init(ObjectClass *klass, void *data) --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609968644; cv=none; d=zohomail.com; s=zohoarc; b=gJj0MwXuheN2r6Vw/e3TUrCZ2ikcfHUJnEKLVVK1mDKN+YhQ/hJnfVfQoH8K48iZbBv8C15rBanAdOpBzukADZWzRkBcoRrHlpBluUhl7R49J7TvALo96xwGUGjwzjtoYBIenSTh8fdX1UcRSMm9MH1su6SYd4aX9G65pXnprJU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609968644; 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=wT66r+Q7+KutwCfpXIPrxcK4klP57N2Dhg4YF+7Y2zs=; b=WF80cVt2OSYT0F2MOMmEPCFPT7dHRVZwPgF1Z9JoKVcmJVptw4SszmasFE/g373LglVff3RwzjArVHlVk9XAEspKFysFFnvS/Vmcp/gV959t0ZqQNL6dkLEjnXr1qZQNZ9RLMIvOEeroO4MlvsdzjUjJRF41W2Bwu5IaNg+fokg= 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 160996864440010.484522163579868; Wed, 6 Jan 2021 13:30:44 -0800 (PST) Received: from localhost ([::1]:43214 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGOB-0004bO-7E for importer@patchew.org; Wed, 06 Jan 2021 16:30:43 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57738) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMY-0002sd-00 for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:02 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:22497) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMU-0001l7-Ae for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:01 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 2D6BA7470F9; Wed, 6 Jan 2021 22:28:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 44BD07470FC; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: <3f3100292a68522d738f75d7a865840eb58ef878.1609967638.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 10/12] vt82c686: QOM-ify superio related functionality Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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=152.66.115.2; envelope-from=balaton@eik.bme.hu; helo=zero.eik.bme.hu X-Spam_score_int: -41 X-Spam_score: -4.2 X-Spam_bar: ---- X-Spam_report: (-4.2 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_MED=-2.3, 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Collect superio functionality and its controlling config registers handling in an abstract VIA_SUPERIO class that is a subclass of ISA_SUPERIO and put vt82c686b specific parts in a subclass of this abstract class. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 240 ++++++++++++++++++++++++-------------- include/hw/isa/vt82c686.h | 1 - 2 files changed, 150 insertions(+), 91 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 26db1a18e2..a755896b8e 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -249,12 +249,21 @@ static const TypeInfo vt8231_pm_info =3D { }; =20 =20 -typedef struct SuperIOConfig { +#define TYPE_VIA_SUPERIO "via-superio" +OBJECT_DECLARE_SIMPLE_TYPE(ViaSuperIOState, VIA_SUPERIO) + +struct ViaSuperIOState { + ISASuperIODevice superio; uint8_t regs[0x100]; + const MemoryRegionOps *io_ops; MemoryRegion io; - ISASuperIODevice *superio; MemoryRegion *serial_io[SUPERIO_MAX_SERIAL_PORTS]; -} SuperIOConfig; +}; + +static inline void via_superio_io_enable(ViaSuperIOState *s, bool enable) +{ + memory_region_set_enabled(&s->io, enable); +} =20 static MemoryRegion *find_subregion(ISADevice *d, MemoryRegion *parent, int offs) @@ -270,10 +279,76 @@ static MemoryRegion *find_subregion(ISADevice *d, Mem= oryRegion *parent, return mr; } =20 -static void superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, - unsigned size) +static void via_superio_realize(DeviceState *d, Error **errp) +{ + ViaSuperIOState *s =3D VIA_SUPERIO(d); + ISASuperIOClass *ic =3D ISA_SUPERIO_GET_CLASS(s); + int i; + + assert(s->io_ops); + ic->parent_realize(d, errp); + if (*errp) { + return; + } + /* Grab io regions of serial devices so we can control them */ + for (i =3D 0; i < ic->serial.count; i++) { + ISADevice *sd =3D s->superio.serial[i]; + MemoryRegion *io =3D isa_address_space_io(sd); + MemoryRegion *mr =3D find_subregion(sd, io, sd->ioport_id); + if (!mr) { + error_setg(errp, "Could not get io region for serial %d", i); + return; + } + s->serial_io[i] =3D mr; + } + + memory_region_init_io(&s->io, OBJECT(d), s->io_ops, s, "via-superio", = 2); + memory_region_set_enabled(&s->io, false); + /* The floppy also uses 0x3f0 and 0x3f1 but this seems to work anyway = */ + memory_region_add_subregion(isa_address_space_io(ISA_DEVICE(s)), 0x3f0, + &s->io); +} + +static uint64_t via_superio_cfg_read(void *opaque, hwaddr addr, unsigned s= ize) +{ + ViaSuperIOState *sc =3D opaque; + uint8_t idx =3D sc->regs[0]; + uint8_t val =3D sc->regs[idx]; + + if (addr =3D=3D 0) { + return idx; + } + if (addr =3D=3D 1 && idx =3D=3D 0) { + val =3D 0; /* reading reg 0 where we store index value */ + } + trace_via_superio_read(idx, val); + return val; +} + +static void via_superio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ISASuperIOClass *sc =3D ISA_SUPERIO_CLASS(klass); + + sc->parent_realize =3D dc->realize; + dc->realize =3D via_superio_realize; +} + +static const TypeInfo via_superio_info =3D { + .name =3D TYPE_VIA_SUPERIO, + .parent =3D TYPE_ISA_SUPERIO, + .instance_size =3D sizeof(ViaSuperIOState), + .class_size =3D sizeof(ISASuperIOClass), + .class_init =3D via_superio_class_init, + .abstract =3D true, +}; + +#define TYPE_VT82C686B_SUPERIO "vt82c686b-superio" + +static void vt82c686b_superio_cfg_write(void *opaque, hwaddr addr, + uint64_t data, unsigned size) { - SuperIOConfig *sc =3D opaque; + ViaSuperIOState *sc =3D opaque; uint8_t idx =3D sc->regs[0]; =20 if (addr =3D=3D 0) { /* config index register */ @@ -295,29 +370,29 @@ static void superio_cfg_write(void *opaque, hwaddr ad= dr, uint64_t data, case 0xfd ... 0xff: /* ignore write to read only registers */ return; - case 0xe2: + case 0xe2: /* Function select */ { data &=3D 0x1f; if (data & BIT(2)) { /* Serial port 1 enable */ - ISADevice *dev =3D sc->superio->serial[0]; + ISADevice *dev =3D sc->superio.serial[0]; if (!memory_region_is_mapped(sc->serial_io[0])) { memory_region_add_subregion(isa_address_space_io(dev), dev->ioport_id, sc->serial_io[= 0]); } } else { - MemoryRegion *io =3D isa_address_space_io(sc->superio->serial[= 0]); + MemoryRegion *io =3D isa_address_space_io(sc->superio.serial[0= ]); if (memory_region_is_mapped(sc->serial_io[0])) { memory_region_del_subregion(io, sc->serial_io[0]); } } if (data & BIT(3)) { /* Serial port 2 enable */ - ISADevice *dev =3D sc->superio->serial[1]; + ISADevice *dev =3D sc->superio.serial[1]; if (!memory_region_is_mapped(sc->serial_io[1])) { memory_region_add_subregion(isa_address_space_io(dev), dev->ioport_id, sc->serial_io[= 1]); } } else { - MemoryRegion *io =3D isa_address_space_io(sc->superio->serial[= 1]); + MemoryRegion *io =3D isa_address_space_io(sc->superio.serial[1= ]); if (memory_region_is_mapped(sc->serial_io[1])) { memory_region_del_subregion(io, sc->serial_io[1]); } @@ -327,7 +402,7 @@ static void superio_cfg_write(void *opaque, hwaddr addr= , uint64_t data, case 0xe7: /* Serial port 1 io base address */ { data &=3D 0xfe; - sc->superio->serial[0]->ioport_id =3D data << 2; + sc->superio.serial[0]->ioport_id =3D data << 2; if (memory_region_is_mapped(sc->serial_io[0])) { memory_region_set_address(sc->serial_io[0], data << 2); } @@ -336,7 +411,7 @@ static void superio_cfg_write(void *opaque, hwaddr addr= , uint64_t data, case 0xe8: /* Serial port 2 io base address */ { data &=3D 0xfe; - sc->superio->serial[1]->ioport_id =3D data << 2; + sc->superio.serial[1]->ioport_id =3D data << 2; if (memory_region_is_mapped(sc->serial_io[1])) { memory_region_set_address(sc->serial_io[1], data << 2); } @@ -350,25 +425,9 @@ static void superio_cfg_write(void *opaque, hwaddr add= r, uint64_t data, sc->regs[idx] =3D data; } =20 -static uint64_t superio_cfg_read(void *opaque, hwaddr addr, unsigned size) -{ - SuperIOConfig *sc =3D opaque; - uint8_t idx =3D sc->regs[0]; - uint8_t val =3D sc->regs[idx]; - - if (addr =3D=3D 0) { - return idx; - } - if (addr =3D=3D 1 && idx =3D=3D 0) { - val =3D 0; /* reading reg 0 where we store index value */ - } - trace_via_superio_read(idx, val); - return val; -} - -static const MemoryRegionOps superio_cfg_ops =3D { - .read =3D superio_cfg_read, - .write =3D superio_cfg_write, +static const MemoryRegionOps vt82c686b_superio_cfg_ops =3D { + .read =3D via_superio_cfg_read, + .write =3D vt82c686b_superio_cfg_write, .endianness =3D DEVICE_NATIVE_ENDIAN, .impl =3D { .min_access_size =3D 1, @@ -376,13 +435,66 @@ static const MemoryRegionOps superio_cfg_ops =3D { }, }; =20 +static void vt82c686b_superio_reset(DeviceState *dev) +{ + ViaSuperIOState *s =3D VIA_SUPERIO(dev); + + memset(s->regs, 0, sizeof(s->regs)); + /* Device ID */ + vt82c686b_superio_cfg_write(s, 0, 0xe0, 1); + vt82c686b_superio_cfg_write(s, 1, 0x3c, 1); + /* Function select - all disabled */ + vt82c686b_superio_cfg_write(s, 0, 0xe2, 1); + vt82c686b_superio_cfg_write(s, 1, 0x03, 1); + /* Floppy ctrl base addr */ + vt82c686b_superio_cfg_write(s, 0, 0xe3, 1); + vt82c686b_superio_cfg_write(s, 1, 0xfc, 1); + /* Parallel port base addr */ + vt82c686b_superio_cfg_write(s, 0, 0xe6, 1); + vt82c686b_superio_cfg_write(s, 1, 0xde, 1); + /* Serial port 1 base addr */ + vt82c686b_superio_cfg_write(s, 0, 0xe7, 1); + vt82c686b_superio_cfg_write(s, 1, 0xfe, 1); + /* Serial port 2 base addr */ + vt82c686b_superio_cfg_write(s, 0, 0xe8, 1); + vt82c686b_superio_cfg_write(s, 1, 0xbe, 1); + + vt82c686b_superio_cfg_write(s, 0, 0, 1); +} + +static void vt82c686b_superio_init(Object *obj) +{ + VIA_SUPERIO(obj)->io_ops =3D &vt82c686b_superio_cfg_ops; +} + +static void vt82c686b_superio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ISASuperIOClass *sc =3D ISA_SUPERIO_CLASS(klass); + + dc->reset =3D vt82c686b_superio_reset; + sc->serial.count =3D 2; + sc->parallel.count =3D 1; + sc->ide.count =3D 0; /* emulated by via-ide */ + sc->floppy.count =3D 1; +} + +static const TypeInfo vt82c686b_superio_info =3D { + .name =3D TYPE_VT82C686B_SUPERIO, + .parent =3D TYPE_VIA_SUPERIO, + .instance_size =3D sizeof(ViaSuperIOState), + .instance_init =3D vt82c686b_superio_init, + .class_size =3D sizeof(ISASuperIOClass), + .class_init =3D vt82c686b_superio_class_init, +}; + =20 OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA) =20 struct VT82C686BISAState { PCIDevice dev; qemu_irq cpu_intr; - SuperIOConfig superio_cfg; + ViaSuperIOState *via_sio; }; =20 static void via_isa_request_i8259_irq(void *opaque, int irq, int level) @@ -400,7 +512,7 @@ static void vt82c686b_write_config(PCIDevice *d, uint32= _t addr, pci_default_write_config(d, addr, val, len); if (addr =3D=3D 0x85) { /* BIT(1): enable or disable superio config io ports */ - memory_region_set_enabled(&s->superio_cfg.io, val & BIT(1)); + via_superio_io_enable(s->via_sio, val & BIT(1)); } } =20 @@ -432,13 +544,6 @@ static void vt82c686b_isa_reset(DeviceState *dev) pci_conf[0x5a] =3D 0x04; /* KBC/RTC Control*/ pci_conf[0x5f] =3D 0x04; pci_conf[0x77] =3D 0x10; /* GPIO Control 1/2/3/4 */ - - s->superio_cfg.regs[0xe0] =3D 0x3c; /* Device ID */ - s->superio_cfg.regs[0xe2] =3D 0x03; /* Function select */ - s->superio_cfg.regs[0xe3] =3D 0xfc; /* Floppy ctrl base addr */ - s->superio_cfg.regs[0xe6] =3D 0xde; /* Parallel port base addr */ - s->superio_cfg.regs[0xe7] =3D 0xfe; /* Serial port 1 base addr */ - s->superio_cfg.regs[0xe8] =3D 0xbe; /* Serial port 2 base addr */ } =20 static void vt82c686b_realize(PCIDevice *d, Error **errp) @@ -447,7 +552,6 @@ static void vt82c686b_realize(PCIDevice *d, Error **err= p) DeviceState *dev =3D DEVICE(d); ISABus *isa_bus; qemu_irq *isa_irq; - ISASuperIOClass *ic; int i; =20 qdev_init_gpio_out(dev, &s->cpu_intr, 1); @@ -457,9 +561,8 @@ static void vt82c686b_realize(PCIDevice *d, Error **err= p) isa_bus_irqs(isa_bus, i8259_init(isa_bus, *isa_irq)); i8254_pit_init(isa_bus, 0x40, 0, NULL); i8257_dma_init(isa_bus, 0); - s->superio_cfg.superio =3D ISA_SUPERIO(isa_create_simple(isa_bus, - TYPE_VT82C686B_SUPER= IO)); - ic =3D ISA_SUPERIO_GET_CLASS(s->superio_cfg.superio); + s->via_sio =3D VIA_SUPERIO(isa_create_simple(isa_bus, + TYPE_VT82C686B_SUPERIO)); mc146818_rtc_init(isa_bus, 2000, NULL); =20 for (i =3D 0; i < PCI_CONFIG_HEADER_SIZE; i++) { @@ -467,31 +570,6 @@ static void vt82c686b_realize(PCIDevice *d, Error **er= rp) d->wmask[i] =3D 0; } } - - memory_region_init_io(&s->superio_cfg.io, OBJECT(d), &superio_cfg_ops, - &s->superio_cfg, "superio_cfg", 2); - memory_region_set_enabled(&s->superio_cfg.io, false); - /* - * The floppy also uses 0x3f0 and 0x3f1. - * But we do not emulate a floppy, so just set it here. - */ - memory_region_add_subregion(isa_bus->address_space_io, 0x3f0, - &s->superio_cfg.io); - - /* Grab io regions of serial devices so we can control them */ - for (i =3D 0; i < ic->serial.count; i++) { - ISADevice *sd =3D s->superio_cfg.superio->serial[i]; - MemoryRegion *io =3D isa_address_space_io(sd); - MemoryRegion *mr =3D find_subregion(sd, io, sd->ioport_id); - if (!mr) { - error_setg(errp, "Could not get io region for serial %d", i); - return; - } - s->superio_cfg.serial_io[i] =3D mr; - if (memory_region_is_mapped(mr)) { - memory_region_del_subregion(io, mr); - } - } } =20 static void via_class_init(ObjectClass *klass, void *data) @@ -527,32 +605,14 @@ static const TypeInfo via_info =3D { }; =20 =20 -static void vt82c686b_superio_class_init(ObjectClass *klass, void *data) -{ - ISASuperIOClass *sc =3D ISA_SUPERIO_CLASS(klass); - - sc->serial.count =3D 2; - sc->parallel.count =3D 1; - sc->ide.count =3D 0; - sc->floppy.count =3D 1; -} - -static const TypeInfo via_superio_info =3D { - .name =3D TYPE_VT82C686B_SUPERIO, - .parent =3D TYPE_ISA_SUPERIO, - .instance_size =3D sizeof(ISASuperIODevice), - .class_size =3D sizeof(ISASuperIOClass), - .class_init =3D vt82c686b_superio_class_init, -}; - - static void vt82c686b_register_types(void) { type_register_static(&via_pm_info); type_register_static(&vt82c686b_pm_info); type_register_static(&vt8231_pm_info); - type_register_static(&via_info); type_register_static(&via_superio_info); + type_register_static(&vt82c686b_superio_info); + type_register_static(&via_info); } =20 type_init(vt82c686b_register_types) diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h index 9b6d610e83..0692b9a527 100644 --- a/include/hw/isa/vt82c686.h +++ b/include/hw/isa/vt82c686.h @@ -2,7 +2,6 @@ #define HW_VT82C686_H =20 #define TYPE_VT82C686B_ISA "vt82c686b-isa" -#define TYPE_VT82C686B_SUPERIO "vt82c686b-superio" #define TYPE_VT82C686B_PM "vt82c686b-pm" #define TYPE_VT8231_PM "vt8231-pm" #define TYPE_VIA_AC97 "via-ac97" --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609968749; cv=none; d=zohomail.com; s=zohoarc; b=FrDhZwEqJo/M/z9lbWn0M3kn2NG+KdhUkxOTJWu9dYkilYe86udJuDra+cSgRy3IzXR3yENVYEKh8SFC7uWb00I0nLu8+0Czk92MpPzpyoIiV83xucUPZx9oYnqGofvZlSyufCz/nwmuA6ksiYFHG9cPbF3Zse0zFbkyLHt2Pts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609968749; 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=tbVUmNzBV7zhUU9oGA/AdDO7pwxbQIzS6IstyLWRfbk=; b=fc4VPYlDyr9q/0P1t/w+jY8wA7ceVQmQJE4ge3Ie+J9zbPPoURvM93Fa1KNcDNQasH7mzo5cN/vBFrTZHB5FuedQmaWApls4r4HZLhot7RV+PuD4ivvoPMoQl/IQ9UCWYFLO+YlFOh2yeGfrKKt/C0743lQC3ad1Y3bqUyhw8n4= 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 1609968749071442.39316572325174; Wed, 6 Jan 2021 13:32:29 -0800 (PST) Received: from localhost ([::1]:47948 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGPq-0006kg-SK for importer@patchew.org; Wed, 06 Jan 2021 16:32:26 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57766) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMZ-0002vd-2M for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:03 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:22499) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMV-0001lH-9z for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:02 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 3EA8A7470FB; Wed, 6 Jan 2021 22:28:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 493357475FB; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: <10265defd598f8903c01f0cb8bb3c6b5c6413634.1609967638.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 11/12] vt82c686: Add VT8231_SUPERIO based on VIA_SUPERIO Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" The VT8231 south bridge is very similar to VT82C686B but there are some differences in register addresses and functionality, e.g. the VT8231 only has one serial port. This commit adds VT8231_SUPERIO subclass based on the abstract VIA_SUPERIO class to emulate the superio part of VT8231. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 121 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 121 insertions(+) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index a755896b8e..0390782d1d 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -489,6 +489,126 @@ static const TypeInfo vt82c686b_superio_info =3D { }; =20 =20 +#define TYPE_VT8231_SUPERIO "vt8231-superio" + +static void vt8231_superio_cfg_write(void *opaque, hwaddr addr, + uint64_t data, unsigned size) +{ + ViaSuperIOState *sc =3D opaque; + uint8_t idx =3D sc->regs[0]; + + if (addr =3D=3D 0) { /* config index register */ + sc->regs[0] =3D data; + return; + } + + /* config data register */ + trace_via_superio_write(idx, data); + switch (idx) { + case 0x00 ... 0xdf: + case 0xe7 ... 0xef: + case 0xf0 ... 0xf1: + case 0xf5: + case 0xf8: + case 0xfd: + /* ignore write to read only registers */ + return; + case 0xf2: /* Function select */ + { + data &=3D 0x17; + if (data & BIT(2)) { /* Serial port enable */ + ISADevice *dev =3D sc->superio.serial[0]; + if (!memory_region_is_mapped(sc->serial_io[0])) { + memory_region_add_subregion(isa_address_space_io(dev), + dev->ioport_id, sc->serial_io[= 0]); + } + } else { + MemoryRegion *io =3D isa_address_space_io(sc->superio.serial[0= ]); + if (memory_region_is_mapped(sc->serial_io[0])) { + memory_region_del_subregion(io, sc->serial_io[0]); + } + } + break; + } + case 0xf4: /* Serial port io base address */ + { + data &=3D 0xfe; + sc->superio.serial[0]->ioport_id =3D data << 2; + if (memory_region_is_mapped(sc->serial_io[0])) { + memory_region_set_address(sc->serial_io[0], data << 2); + } + break; + } + default: + qemu_log_mask(LOG_UNIMP, + "via_superio_cfg: unimplemented register 0x%x\n", id= x); + break; + } + sc->regs[idx] =3D data; +} + +static const MemoryRegionOps vt8231_superio_cfg_ops =3D { + .read =3D via_superio_cfg_read, + .write =3D vt8231_superio_cfg_write, + .endianness =3D DEVICE_NATIVE_ENDIAN, + .impl =3D { + .min_access_size =3D 1, + .max_access_size =3D 1, + }, +}; + +static void vt8231_superio_reset(DeviceState *dev) +{ + ViaSuperIOState *s =3D VIA_SUPERIO(dev); + + memset(s->regs, 0, sizeof(s->regs)); + /* Device ID */ + s->regs[0xf0] =3D 0x3c; + /* Device revision */ + s->regs[0xf1] =3D 0x01; + /* Function select - all disabled */ + vt8231_superio_cfg_write(s, 0, 0xf2, 1); + vt8231_superio_cfg_write(s, 1, 0x03, 1); + /* Serial port base addr */ + vt8231_superio_cfg_write(s, 0, 0xf4, 1); + vt8231_superio_cfg_write(s, 1, 0xfe, 1); + /* Parallel port base addr */ + vt8231_superio_cfg_write(s, 0, 0xf6, 1); + vt8231_superio_cfg_write(s, 1, 0xde, 1); + /* Floppy ctrl base addr */ + vt8231_superio_cfg_write(s, 0, 0xf7, 1); + vt8231_superio_cfg_write(s, 1, 0xfc, 1); + + vt8231_superio_cfg_write(s, 0, 0, 1); +} + +static void vt8231_superio_init(Object *obj) +{ + VIA_SUPERIO(obj)->io_ops =3D &vt8231_superio_cfg_ops; +} + +static void vt8231_superio_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + ISASuperIOClass *sc =3D ISA_SUPERIO_CLASS(klass); + + dc->reset =3D vt8231_superio_reset; + sc->serial.count =3D 1; + sc->parallel.count =3D 1; + sc->ide.count =3D 0; /* emulated by via-ide */ + sc->floppy.count =3D 1; +} + +static const TypeInfo vt8231_superio_info =3D { + .name =3D TYPE_VT8231_SUPERIO, + .parent =3D TYPE_VIA_SUPERIO, + .instance_size =3D sizeof(ViaSuperIOState), + .instance_init =3D vt8231_superio_init, + .class_size =3D sizeof(ISASuperIOClass), + .class_init =3D vt8231_superio_class_init, +}; + + OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA) =20 struct VT82C686BISAState { @@ -612,6 +732,7 @@ static void vt82c686b_register_types(void) type_register_static(&vt8231_pm_info); type_register_static(&via_superio_info); type_register_static(&vt82c686b_superio_info); + type_register_static(&vt8231_superio_info); type_register_static(&via_info); } =20 --=20 2.21.3 From nobody Fri Apr 19 22:10:55 2024 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=1609969027; cv=none; d=zohomail.com; s=zohoarc; b=YsHw+3w/yQlbPAHL2d3KRhJS7gra4gKPGMHiKdcGLup+VwSqN2eu7pnFDgB7C6zd4wumXEKPeB+Cai7PBpjlYr9+D9RSPxO3ri0NkCXuxRrp1vDpNxINEGvsPX8O06MZwTiHfoVS2e5WtdzZJS44jmj1+4BG9X4lYnfM6qSSVCo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609969027; 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=fwWBqLXMLJPLanVITzkKURFYk7rkIxz57YzCuQKPLIc=; b=CeC0+bveCJAGOh2vGGq+cr0DiILVN+blPIGr/clT/yX+Q+jaH7t0QZ2iYEzRED+yYsAtT9oKECIMKMfieVM06OnP7UBIT/4BmyyMJlOSLPxpdhRE/YsI51a16A7Eaf/Sy3hADw+20Osfv9Wad7CxaGe8FF2+AHWWRvxKaVRKJZ8= 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 16099690272051014.0561837738791; Wed, 6 Jan 2021 13:37:07 -0800 (PST) Received: from localhost ([::1]:59884 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kxGUM-0003oF-0t for importer@patchew.org; Wed, 06 Jan 2021 16:37:06 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:57798) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMa-00030G-Qq for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:04 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:22500) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kxGMW-0001lK-8Z for qemu-devel@nongnu.org; Wed, 06 Jan 2021 16:29:04 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 697FA7470FC; Wed, 6 Jan 2021 22:28:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 4EE9E7470DF; Wed, 6 Jan 2021 22:28:51 +0100 (CET) Message-Id: <3e90ffc99bca628ddab2e56632389394fc501abf.1609967638.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 12/12] vt82c686: Add emulation of VT8231 south bridge Date: Wed, 06 Jan 2021 22:13:58 +0100 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable To: qemu-devel@nongnu.org X-Spam-Probability: 8% 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: Huacai Chen , f4bug@amsat.org Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Type: text/plain; charset="utf-8" Add emulation of VT8231 south bridge ISA part based on the similar VT82C686B but implemented in a separate subclass that holds the differences while reusing parts that can be shared. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 152 ++++++++++++++++++++++++++++++-------- include/hw/isa/vt82c686.h | 1 + 2 files changed, 123 insertions(+), 30 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 0390782d1d..604ab4a55e 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -8,6 +8,9 @@ * * Contributions after 2012-01-13 are licensed under the terms of the * GNU GPL, version 2 or (at your option) any later version. + * + * VT8231 south bridge support and general clean up to allow it + * Copyright (c) 2018-2020 BALATON Zoltan */ =20 #include "qemu/osdep.h" @@ -609,24 +612,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 +663,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 +685,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 +709,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); @@ -706,22 +723,95 @@ static void via_class_init(ObjectClass *klass, void *= data) 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, +}; + +/* TYPE_VT8231_ISA */ + +static void vt8231_write_config(PCIDevice *d, uint32_t addr, + uint32_t val, int len) +{ + ViaISAState *s =3D VIA_ISA(d); + + trace_via_isa_write(addr, val, len); + pci_default_write_config(d, addr, val, len); + if (addr =3D=3D 0x50) { + /* BIT(2): enable or disable superio config io ports */ + via_superio_io_enable(s->via_sio, val & BIT(2)); + } +} + +static void vt8231_isa_reset(DeviceState *dev) +{ + ViaISAState *s =3D VIA_ISA(dev); + uint8_t *pci_conf =3D s->dev.config; + + pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); + pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMO= RY | + PCI_COMMAND_MASTER | PCI_COMMAND_SPECIAL); + pci_set_word(pci_conf + PCI_STATUS, PCI_STATUS_DEVSEL_MEDIUM); + + pci_conf[0x58] =3D 0x40; /* Miscellaneous Control 0 */ + pci_conf[0x67] =3D 0x08; /* Fast IR Config */ + pci_conf[0x6b] =3D 0x01; /* Fast IR I/O Base */ +} + +static void vt8231_realize(PCIDevice *d, Error **errp) +{ + ViaISAState *s =3D VIA_ISA(d); + DeviceState *dev =3D DEVICE(d); + ISABus *isa_bus; + qemu_irq *isa_irq; + int i; + + qdev_init_gpio_out(dev, &s->cpu_intr, 1); + isa_irq =3D qemu_allocate_irqs(via_isa_request_i8259_irq, s, 1); + isa_bus =3D isa_bus_new(dev, get_system_memory(), pci_address_space_io= (d), + &error_fatal); + isa_bus_irqs(isa_bus, i8259_init(isa_bus, *isa_irq)); + i8254_pit_init(isa_bus, 0x40, 0, NULL); + i8257_dma_init(isa_bus, 0); + s->via_sio =3D VIA_SUPERIO(isa_create_simple(isa_bus, TYPE_VT8231_SUPE= RIO)); + mc146818_rtc_init(isa_bus, 2000, NULL); + + for (i =3D 0; i < PCI_CONFIG_HEADER_SIZE; i++) { + if (i < PCI_COMMAND || i >=3D PCI_REVISION_ID) { + d->wmask[i] =3D 0; + } + } +} + +static void vt8231_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc =3D DEVICE_CLASS(klass); + PCIDeviceClass *k =3D PCI_DEVICE_CLASS(klass); + + k->realize =3D vt8231_realize; + k->config_write =3D vt8231_write_config; + k->vendor_id =3D PCI_VENDOR_ID_VIA; + k->device_id =3D 0x8231; + k->class_id =3D PCI_CLASS_BRIDGE_ISA; + k->revision =3D 0x10; + dc->reset =3D vt8231_isa_reset; + dc->desc =3D "ISA bridge"; + dc->vmsd =3D &vmstate_via; + /* Reason: part of VIA VT8231 southbridge, needs to be wired up */ + dc->user_creatable =3D false; +} + +static const TypeInfo vt8231_isa_info =3D { + .name =3D TYPE_VT8231_ISA, + .parent =3D TYPE_VIA_ISA, + .instance_size =3D sizeof(ViaISAState), + .class_init =3D vt8231_class_init, }; =20 =20 @@ -733,7 +823,9 @@ 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); + type_register_static(&vt8231_isa_info); } =20 type_init(vt82c686b_register_types) diff --git a/include/hw/isa/vt82c686.h b/include/hw/isa/vt82c686.h index 0692b9a527..0f01aaa471 100644 --- a/include/hw/isa/vt82c686.h +++ b/include/hw/isa/vt82c686.h @@ -3,6 +3,7 @@ =20 #define TYPE_VT82C686B_ISA "vt82c686b-isa" #define TYPE_VT82C686B_PM "vt82c686b-pm" +#define TYPE_VT8231_ISA "vt8231-isa" #define TYPE_VT8231_PM "vt8231-pm" #define TYPE_VIA_AC97 "via-ac97" #define TYPE_VIA_MC97 "via-mc97" --=20 2.21.3