From nobody Tue Nov 18 07:45:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1609283675; cv=none; d=zohomail.com; s=zohoarc; b=Biga9IC/Zint+fRmXvPI2hvlmSKRQjbn254mHcATE106c5UuNKpXbRkDjauAT58qqr/LtZsAlJ8CzunFbc34wREVrmAW7I3PxVwelCLqIZR6lFZh3DOyIqiTvCSS91byKbNYqyCab8Bd5YSk4tt195x8Pq969dV5iBlxT9c1RQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609283675; 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:Reply-To:References:Sender:Subject:To; bh=acG7oPWRH0JeoFqjY5rn/mzz9Lnb/ZrMmSClA9XbLXs=; b=mU38fXr45aGT/R/ReCGaCkbP94FSvjx00cartJxbtwRyerTrLZtw9yFphPkxgV6WoIDrAo8udofT8iMMsCSBbKbX1hiDgEG1RhisBMz0+tZmAacHr3ETB6Xzmlp0ihBNvY9DFEBUNxXnW6PMTpXUzz3j4BUWLKz+3uj8iWjGkRw= 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=pass 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 1609283675747553.6013311073095; Tue, 29 Dec 2020 15:14:35 -0800 (PST) Received: from localhost ([::1]:50340 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuOCI-0005nc-NB for importer@patchew.org; Tue, 29 Dec 2020 18:14:34 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53770) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO80-00004y-IB for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:08 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:48956) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7n-0006bf-9A for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:08 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 2DFC57470F1; Wed, 30 Dec 2020 00:09:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 9330F7470DB; Wed, 30 Dec 2020 00:09:51 +0100 (CET) Message-Id: In-Reply-To: References: Subject: [PATCH 1/7] vt82c686: Use shorter name for local variable holding object state Date: Tue, 29 Dec 2020 23:50:53 +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" Reply-to: BALATON Zoltan From: BALATON Zoltan via Content-Type: text/plain; charset="utf-8" Rename local variable holding object state for readability and consistency. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 02d6759c00..2633cfe7dc 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -95,8 +95,8 @@ static const MemoryRegionOps superio_ops =3D { =20 static void vt82c686b_isa_reset(DeviceState *dev) { - VT82C686BISAState *vt82c =3D VT82C686B_ISA(dev); - uint8_t *pci_conf =3D vt82c->dev.config; + VT82C686BISAState *s =3D VT82C686B_ISA(dev); + uint8_t *pci_conf =3D s->dev.config; =20 pci_set_long(pci_conf + PCI_CAPABILITY_LIST, 0x000000c0); pci_set_word(pci_conf + PCI_COMMAND, PCI_COMMAND_IO | PCI_COMMAND_MEMO= RY | @@ -112,24 +112,24 @@ static void vt82c686b_isa_reset(DeviceState *dev) pci_conf[0x5f] =3D 0x04; pci_conf[0x77] =3D 0x10; /* GPIO Control 1/2/3/4 */ =20 - vt82c->superio_conf.config[0xe0] =3D 0x3c; - vt82c->superio_conf.config[0xe2] =3D 0x03; - vt82c->superio_conf.config[0xe3] =3D 0xfc; - vt82c->superio_conf.config[0xe6] =3D 0xde; - vt82c->superio_conf.config[0xe7] =3D 0xfe; - vt82c->superio_conf.config[0xe8] =3D 0xbe; + s->superio_conf.config[0xe0] =3D 0x3c; + s->superio_conf.config[0xe2] =3D 0x03; + s->superio_conf.config[0xe3] =3D 0xfc; + s->superio_conf.config[0xe6] =3D 0xde; + s->superio_conf.config[0xe7] =3D 0xfe; + s->superio_conf.config[0xe8] =3D 0xbe; } =20 /* write config pci function0 registers. PCI-ISA bridge */ static void vt82c686b_write_config(PCIDevice *d, uint32_t addr, uint32_t val, int len) { - VT82C686BISAState *vt686 =3D VT82C686B_ISA(d); + VT82C686BISAState *s =3D VT82C686B_ISA(d); =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(&vt686->superio, val & 0x2); + memory_region_set_enabled(&s->superio, val & 0x2); } } =20 @@ -289,7 +289,7 @@ static const VMStateDescription vmstate_via =3D { /* init the PCI-to-ISA bridge */ static void vt82c686b_realize(PCIDevice *d, Error **errp) { - VT82C686BISAState *vt82c =3D VT82C686B_ISA(d); + VT82C686BISAState *s =3D VT82C686B_ISA(d); uint8_t *pci_conf; ISABus *isa_bus; uint8_t *wmask; @@ -311,15 +311,15 @@ static void vt82c686b_realize(PCIDevice *d, Error **e= rrp) } } =20 - memory_region_init_io(&vt82c->superio, OBJECT(d), &superio_ops, - &vt82c->superio_conf, "superio", 2); - memory_region_set_enabled(&vt82c->superio, false); + memory_region_init_io(&s->superio, OBJECT(d), &superio_ops, + &s->superio_conf, "superio", 2); + memory_region_set_enabled(&s->superio, 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, - &vt82c->superio); + &s->superio); } =20 static void via_class_init(ObjectClass *klass, void *data) --=20 2.21.3 From nobody Tue Nov 18 07:45:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1609283533; cv=none; d=zohomail.com; s=zohoarc; b=GlbdGb4S8xOA5K8UQycbM2+Iz+yYQLk7kacP1PM/SuOcQvyr6iGej5jKDEg564f1xWwa4FD3+e830b35su+r3lWPxRNgyYoZQJe2P5V9MmNuJ3MCtQXpddT9tsNNvhxGxUM/Yy/LgolAZuU5LeVgV+8eoQhkU4DZgcC4GDnIUHY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609283533; 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:Reply-To:References:Sender:Subject:To; bh=VKrycvbN3vhNaPdXUZ4JEvhlG5GjFpmfJlaaFhV8+do=; b=cSOMf5ffnt3/pRM1PL+33eFjHsA97RKG+LvupHvF/PtPcAqrtF9HLM9m22+3bOy7ycYfXF8f2TbsqggRaDd6vvLN5N3KQBN1GG3nRXTSE8VhQG6aeO+UXUy2h+lEloz6uM0R86px6vW/6+pP68/+TeH6LUs0YLWf2LNSzf4/XPY= 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=pass 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 160928353371689.38788020389211; Tue, 29 Dec 2020 15:12:13 -0800 (PST) Received: from localhost ([::1]:41234 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuO9z-0001z1-FV for importer@patchew.org; Tue, 29 Dec 2020 18:12:11 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53682) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7s-0008SL-RP for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:01 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:48957) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7n-0006bh-9P for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:00 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 3327E7470F2; Wed, 30 Dec 2020 00:09:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 974527470E0; Wed, 30 Dec 2020 00:09:51 +0100 (CET) Message-Id: <93f3b97f84dbc04f9bb0157b558d728ff4f1a526.1609282253.git.balaton@eik.bme.hu> In-Reply-To: References: Subject: [PATCH 2/7] vt82c686: Rename superio config related parts Date: Tue, 29 Dec 2020 23:50:53 +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" Reply-to: BALATON Zoltan From: BALATON Zoltan via Content-Type: text/plain; charset="utf-8" Use less confusing naming for superio config register handling related parts that makes it clearer what belongs to this part. Signed-off-by: BALATON Zoltan --- hw/isa/vt82c686.c | 48 +++++++++++++++++++++++------------------------ 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/hw/isa/vt82c686.c b/hw/isa/vt82c686.c index 2633cfe7dc..a6f5a0843d 100644 --- a/hw/isa/vt82c686.c +++ b/hw/isa/vt82c686.c @@ -27,7 +27,7 @@ #include "trace.h" =20 typedef struct SuperIOConfig { - uint8_t config[0x100]; + uint8_t regs[0x100]; uint8_t index; uint8_t data; } SuperIOConfig; @@ -35,23 +35,23 @@ typedef struct SuperIOConfig { struct VT82C686BISAState { PCIDevice dev; MemoryRegion superio; - SuperIOConfig superio_conf; + SuperIOConfig superio_cfg; }; =20 OBJECT_DECLARE_SIMPLE_TYPE(VT82C686BISAState, VT82C686B_ISA) =20 -static void superio_ioport_writeb(void *opaque, hwaddr addr, uint64_t data, - unsigned size) +static void superio_cfg_write(void *opaque, hwaddr addr, uint64_t data, + unsigned size) { - SuperIOConfig *superio_conf =3D opaque; + SuperIOConfig *sc =3D opaque; =20 if (addr =3D=3D 0x3f0) { /* config index register */ - superio_conf->index =3D data & 0xff; + sc->index =3D data & 0xff; } else { bool can_write =3D true; /* 0x3f1, config data register */ - trace_via_superio_write(superio_conf->index, data & 0xff); - switch (superio_conf->index) { + trace_via_superio_write(sc->index, data & 0xff); + switch (sc->index) { case 0x00 ... 0xdf: case 0xe4: case 0xe5: @@ -69,23 +69,23 @@ static void superio_ioport_writeb(void *opaque, hwaddr = addr, uint64_t data, =20 } if (can_write) { - superio_conf->config[superio_conf->index] =3D data & 0xff; + sc->regs[sc->index] =3D data & 0xff; } } } =20 -static uint64_t superio_ioport_readb(void *opaque, hwaddr addr, unsigned s= ize) +static uint64_t superio_cfg_read(void *opaque, hwaddr addr, unsigned size) { - SuperIOConfig *superio_conf =3D opaque; - uint8_t val =3D superio_conf->config[superio_conf->index]; + SuperIOConfig *sc =3D opaque; + uint8_t val =3D sc->regs[sc->index]; =20 - trace_via_superio_read(superio_conf->index, val); + trace_via_superio_read(sc->index, val); return val; } =20 -static const MemoryRegionOps superio_ops =3D { - .read =3D superio_ioport_readb, - .write =3D superio_ioport_writeb, +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, @@ -112,12 +112,12 @@ static void vt82c686b_isa_reset(DeviceState *dev) pci_conf[0x5f] =3D 0x04; pci_conf[0x77] =3D 0x10; /* GPIO Control 1/2/3/4 */ =20 - s->superio_conf.config[0xe0] =3D 0x3c; - s->superio_conf.config[0xe2] =3D 0x03; - s->superio_conf.config[0xe3] =3D 0xfc; - s->superio_conf.config[0xe6] =3D 0xde; - s->superio_conf.config[0xe7] =3D 0xfe; - s->superio_conf.config[0xe8] =3D 0xbe; + 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 /* write config pci function0 registers. PCI-ISA bridge */ @@ -311,8 +311,8 @@ static void vt82c686b_realize(PCIDevice *d, Error **err= p) } } =20 - memory_region_init_io(&s->superio, OBJECT(d), &superio_ops, - &s->superio_conf, "superio", 2); + memory_region_init_io(&s->superio, OBJECT(d), &superio_cfg_ops, + &s->superio_cfg, "superio", 2); memory_region_set_enabled(&s->superio, false); /* * The floppy also uses 0x3f0 and 0x3f1. --=20 2.21.3 From nobody Tue Nov 18 07:45:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1609283661; cv=none; d=zohomail.com; s=zohoarc; b=QjLv6hKAs9D8V90HoIAbMEsbAx4TB+ua4IvntRx3IakxU197zC08HuVAPXQCTiR3RLPXEply7vm0QysYeVmsvFxmGzjHFuNCDj73FSDR5DCg5fLxDIHZc76uIxW4zBEqP5GF0kdZ6VPmnFz6io56tzG+pQw+FOYsY7sXcHQSpks= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609283661; 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:Reply-To:References:Sender:Subject:To; bh=vAtjD/KSUgK+x2dVtRFxacjIt6Sp35D3XKrZ92aIeac=; b=TK67AZaWtGFhPbNso4je4sKGxp44KDTwFdeQmIwACpPMY7LGzqye1c2CwuirZIe6udwWaQk4DC5gD9DJcuwho7s3Rr48Zk1p6U0uPAAMZYYvNnGKwGduxlhUqCGRiZb8J0v14P+O0C44fVHn33PV+eSN9ixJdv3tyfjxs260stM= 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=pass 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 1609283661416542.6720509424849; Tue, 29 Dec 2020 15:14:21 -0800 (PST) Received: from localhost ([::1]:49806 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuOC4-0005aS-9C for importer@patchew.org; Tue, 29 Dec 2020 18:14:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53712) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7u-0008Sy-Ax for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:02 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:48958) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7n-0006bi-8l for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:01 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 2AE667470EE; Wed, 30 Dec 2020 00:09:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id 9D4837470E6; Wed, 30 Dec 2020 00:09:51 +0100 (CET) Message-Id: In-Reply-To: References: Subject: [PATCH 3/7] vt82c686: Move superio memory region to SuperIOConfig struct Date: Tue, 29 Dec 2020 23:50:53 +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" Reply-to: BALATON Zoltan From: BALATON Zoltan via 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 Tue Nov 18 07:45:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1609283535; cv=none; d=zohomail.com; s=zohoarc; b=QOLVT9UKwAIeb3XrX7RgDAaTFsMoho2+Odt8AH+87EjOo4wTVo2gYACe+vW18pHHhAsRkU5ZZExkSqVzl3ssAbogTZTE7++PGdFu+qpDYihxcGiU0j+Ws0kshdinwmJ/xrIzq5iA5O5+J2T6pfuj9YFG4PbbqS3rQmXtHZIk0jA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609283535; 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:Reply-To:References:Sender:Subject:To; bh=nlsxPvyuGk89RXASSHTh/jPGSDvu+wyosvNrFbwO8eI=; b=nFAdVIbRVAqaFdI3xx1hwBOVYXteMK+aST7D4c8pCbuNShSXLmG76Dobfqdd63WI8tw6uELK4O60kJdGSfgLyyZ0OHcx5aA6lZpRjl/oLgjyCDSHJzSwi8jMsf+3rPWV08swD0pnWicQKIwoJ5YxwGivQfGQPBvbToXK/2Cga2A= 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=pass 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 160928353552382.60866897069093; Tue, 29 Dec 2020 15:12:15 -0800 (PST) Received: from localhost ([::1]:41344 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuOA1-00021n-F7 for importer@patchew.org; Tue, 29 Dec 2020 18:12:13 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53714) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7u-0008TB-EJ for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:02 -0500 Received: from zero.eik.bme.hu ([152.66.115.2]:48954) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7n-0006bg-9A for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:02 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 676377470DB; Wed, 30 Dec 2020 00:09:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id A36857470DF; Wed, 30 Dec 2020 00:09:51 +0100 (CET) Message-Id: <0912c67fe6e99fd085e804288773d3f865b4b4a8.1609282253.git.balaton@eik.bme.hu> In-Reply-To: References: Subject: [PATCH 4/7] vt82c686: Reorganise code Date: Tue, 29 Dec 2020 23:50:53 +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" Reply-to: BALATON Zoltan From: BALATON Zoltan via 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's defined and what parts belong to which object. Signed-off-by: BALATON Zoltan --- 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 Tue Nov 18 07:45:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1609283538; cv=none; d=zohomail.com; s=zohoarc; b=O43Z2ubOxsLRMWpTfaDNtWYeqeGilmAuWsEfVnCtAR5MrdXyiIoqUmtTqsV7iPMEnXsgNWTS9AzfgX5XEG/6PpTfKCFR1UPuaTt7v0gQ83JBjuZAQiOOVllha2IAFPtblJR7o7q3b2iUvR7KjKAhjLvSalYhxEX/X1N4YisWwp8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609283538; 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:Reply-To:References:Sender:Subject:To; bh=cxuoyoBsD5WBwtn97fajxek4wgbwJeF4107LVVs7qsE=; b=Uos8mcdcuY90G2bDWQNJI+spfrEwJYSepHXdftIEKBIkYQBWjUEkzb4GSosuEK7cOWZ6xcLNeetMGZ/pVJGe49rSoZyddQznz9Esrl3WgDMgZkQe97n7/qDGY7VgsqG0ZtFHDWdJ6CaXIShXyaGwO6oX8XwVH0SniSPBOk+s7Fg= 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=pass 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 1609283538741446.1509950529429; Tue, 29 Dec 2020 15:12:18 -0800 (PST) Received: from localhost ([::1]:41570 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuOA5-00028o-8f for importer@patchew.org; Tue, 29 Dec 2020 18:12:17 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53742) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7w-0008Tq-NU for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:06 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:48972) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7t-0006dk-RQ for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:04 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 695047470E6; Wed, 30 Dec 2020 00:09:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id A8D087470E3; Wed, 30 Dec 2020 00:09:51 +0100 (CET) Message-Id: <69e844ecc1970e40842ddfb8d500d7d99be1f4af.1609282253.git.balaton@eik.bme.hu> In-Reply-To: References: Subject: [PATCH 5/7] vt82c686: Fix SMBus IO base and configuration registers Date: Tue, 29 Dec 2020 23:50:53 +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" Reply-to: BALATON Zoltan From: BALATON Zoltan via 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 f393509633..bf19b4603e 100644 --- a/hw/mips/fuloong2e.c +++ b/hw/mips/fuloong2e.c @@ -263,9 +263,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 Tue Nov 18 07:45:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1609283663; cv=none; d=zohomail.com; s=zohoarc; b=Q0xGszd79tpOpFrAXTeEsMuC+YfwlRqy4tXPZgg3o7NJLgCebLaoZZc116EpNnXy7NU2Rl9CnrxNVqVa81Xpp010+2qcYFdwI6ctlcoo2hdKExWzFoDvpZBKjmkZRfgP59uYwQ+Lji+FQUMmohHgbVRNvggvAaDDO0Pc+TtLhQI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609283663; 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:Reply-To:References:Sender:Subject:To; bh=Eus0gP+B4s8nxNrfp7rHyhhoRMG3B4HDlIH7LfsezZc=; b=a3DPivY+yhc4xavdD//6aZ3o7arjmkACwVu2yEo07YAmu5WpnQ41MOtSM+iHlLlDm6NOnTjkoQSvb9JIyYayEWYi2/66+BFjH32YTm+ZpDO0NS0W+z8HyNIwYnOqrAe8kiFzLQhH7sVfCmhxPiDYlYoeFNR89vc4Kb3M6cOMnl0= 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=pass 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 160928366386965.9994928118249; Tue, 29 Dec 2020 15:14:23 -0800 (PST) Received: from localhost ([::1]:49974 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuOC6-0005ea-R5 for importer@patchew.org; Tue, 29 Dec 2020 18:14:22 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53758) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7y-0008VK-IM for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:06 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:48973) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7t-0006dm-RH for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:06 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 720B37470DF; Wed, 30 Dec 2020 00:09:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id AE7027470E8; Wed, 30 Dec 2020 00:09:51 +0100 (CET) Message-Id: <4e434754b18bf16ca5d48c8bb22b5aefb375f368.1609282253.git.balaton@eik.bme.hu> In-Reply-To: References: Subject: [PATCH 6/7] vt82c686: Fix up power management io base and config Date: Tue, 29 Dec 2020 23:50:53 +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" Reply-to: BALATON Zoltan From: BALATON Zoltan via Content-Type: text/plain; charset="utf-8" Similar to the SMBus io registers there is a power management io range that's 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 or emulating any of the acrual io registers. Some of these 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 I've added empty io range logging access. I think the pm timer should be hooked up here but not sure guests need it. PMON on fuloong2e sets 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 Tue Nov 18 07:45:25 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1609283664; cv=none; d=zohomail.com; s=zohoarc; b=erS1TvSfE/G4zrcEqf3b+ihrcKDcfKS75LoDauEfglTlbHTalmbyJjkLJ5ysUv8FNeCCuBVLPYn4ANabD2J2iuvj/6IhIdGGzKgrIwOr1qODZS46CoxQkx4cbS5yGnDxhaYQY/wx9ExMFRN4izbvlz8i1W5j+LUqdImB2QApLJM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1609283664; 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:Reply-To:References:Sender:Subject:To; bh=TJGHGbSzKfxVeIk9rUf0FFt0OHvqllLXZLsgwVsN6vk=; b=BmDhWq1dnMWKNWGBFgKLrVk5NBCZLnk+h1fgaj2n7khvXL1JAlewhRHmP0FVHTTFC8zruPCpnezvYYpJ/bpyHQIT92Xxeh7tMydFRExkx4Uo/LJI++CbC7YLlEX83Db3j3JWovpu7eBlmZwFEJRYZWXrHRIu/FdEWdLwk5cpL90= 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=pass 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 1609283664921279.3334114449175; Tue, 29 Dec 2020 15:14:24 -0800 (PST) Received: from localhost ([::1]:50142 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1kuOC7-0005iX-So for importer@patchew.org; Tue, 29 Dec 2020 18:14:23 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:53760) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7z-0008WN-Ab for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:08 -0500 Received: from zero.eik.bme.hu ([2001:738:2001:2001::2001]:48976) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1kuO7v-0006fA-KJ for qemu-devel@nongnu.org; Tue, 29 Dec 2020 18:10:07 -0500 Received: from zero.eik.bme.hu (blah.eik.bme.hu [152.66.115.182]) by localhost (Postfix) with SMTP id 865117470E0; Wed, 30 Dec 2020 00:09:52 +0100 (CET) Received: by zero.eik.bme.hu (Postfix, from userid 432) id B2DD07470ED; Wed, 30 Dec 2020 00:09:51 +0100 (CET) Message-Id: <6b036c8a332155373d8e23ba64204a8b5ba23053.1609282253.git.balaton@eik.bme.hu> In-Reply-To: References: Subject: [PATCH 7/7] vt82c686: Make vt82c686b-pm an abstract base class and add vt8231-pm based on it Date: Tue, 29 Dec 2020 23:50:53 +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" Reply-to: BALATON Zoltan From: BALATON Zoltan via 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 model 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..2e269a2c0f 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_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_init_info, +}; + +static const ViaPMInitInfo vt8231_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_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