From nobody Mon Feb 9 18:19:21 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; 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=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1654282764; cv=none; d=zohomail.com; s=zohoarc; b=fcJhpQzwIKKmphLoW5wVe+QQUzlqB8l3jXvCPwSlbzPcgWm419ZHnds6X4ZuQQDvV/Fst1KswjCSyDnoLvGA5CMM+1QUcl7LLzDD6WUzxo4RcP3WeaLOCj4Ih9DzTyfGuVbsCFkxmtnqqjFrehNndl6aCTagIpqcPaGdq7m4zJs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654282764; 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=INWHJdCEzGhmN69hiuG+Qj1A8L6gKWutj0DTiMvIB5Q=; b=aP16CxqSak7ZXFog6Dd+YMeZ/wE4sl6QINgKHN6hw0CWw+CVo5/2ylEda9xVATks3AvOB6pq4SZDswn0BB0L7E5JJskLsyU81ef09SwBC4VI8Hb7Jjn/IqvVJBEWSb6IZZqpBGjUhJZPJMzFAbcctj90x/tWZM1Z8Fk47eXFKBE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; 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) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1654282764355285.15352623340095; Fri, 3 Jun 2022 11:59:24 -0700 (PDT) Received: from localhost ([::1]:36348 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1nxCW3-0003QP-6f for importer@patchew.org; Fri, 03 Jun 2022 14:59:23 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:51088) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1nxCO6-00077V-PF for qemu-devel@nongnu.org; Fri, 03 Jun 2022 14:51:10 -0400 Received: from mail-ed1-x532.google.com ([2a00:1450:4864:20::532]:42814) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1nxCO5-00048x-27 for qemu-devel@nongnu.org; Fri, 03 Jun 2022 14:51:10 -0400 Received: by mail-ed1-x532.google.com with SMTP id n28so11299717edb.9 for ; Fri, 03 Jun 2022 11:51:07 -0700 (PDT) Received: from osoxes.fritz.box (pd9ed79c4.dip0.t-ipconnect.de. [217.237.121.196]) by smtp.gmail.com with ESMTPSA id f25-20020a170906139900b006fe8c831632sm3066160ejc.73.2022.06.03.11.51.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 03 Jun 2022 11:51:06 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=INWHJdCEzGhmN69hiuG+Qj1A8L6gKWutj0DTiMvIB5Q=; b=duuMEbFnpsbxxmA2fiQRqu5AKm5dOhMCahzcDIuBAT9j2mnRZPKAhIL1Fi4GXjHRdx aYJ3hN0PRV0MtFF/9sbmlG0SWRCrjO78G6EAxPD4TgulAb7BbJPZQhvkbWUmh3LBF14O 6Q1EPBv9koimVXv59qlmVM1z3a+uGhPHPaZtg39KOXxv6Mk1GD9YqKkG9KG1kzKrKen8 p+9V6PfBI1smChTpRlyoC3bm5OsVy9tuLC1RdoqOaKfrPlgucdhM4aq6lRHf0wI8qWVX VpOr1+n7GiJTeuq1FXlgIGQoar6pUPMH0W1OMHN9w+V0Ui3//dqmmljvP7GcDiyhcwTs xYTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=INWHJdCEzGhmN69hiuG+Qj1A8L6gKWutj0DTiMvIB5Q=; b=JoqXQuyOoAqez69LYgYZFEsA6IykXM7JMa8JzjA7x2ctFx5mwjLNtqAuGR1H+IXMiB OF+dkjCJN0nYi93RlGrOz3ACZosiDXB9NpHBQV+P6Ax5qah8tUiHzjTaYgNWxho+QvZQ SmHNk2MG0Ujck0hAP6b4g8eSAuP+w11xtBy9RBs0CEiJR30UIRo+K/uohWfhjUoHGMNo zUZJPO+RFKgIR3b6dAsSYZfRYZ/20Fm3WIVAEY5bqwu4kXtGDt36UEOf5w/5e802m+Fy 70jqYYkEDiDO/8zngAApvSGTHtH2e9m6nuUvslXYTEVf06ZRBQroVfnstHbLEmrRybnR akOw== X-Gm-Message-State: AOAM530C9lEwwUrLH0QVtu9wG66qnzjJKMFzxFtG+AbAD6N90aI80oVZ SNr7kd56I1EBxSveDE8Rt3Ed1wwJH5GJvA== X-Google-Smtp-Source: ABdhPJw4tmGLk/1Xp/iEPARnj0s7Ac1Ahx37R88Inrr/3pn8QNJajorqtBOfTk0bUbYmxCQ+DQJHIw== X-Received: by 2002:a05:6402:516e:b0:42d:c48b:b724 with SMTP id d14-20020a056402516e00b0042dc48bb724mr12406610ede.93.1654282266632; Fri, 03 Jun 2022 11:51:06 -0700 (PDT) From: Bernhard Beschow To: qemu-devel@nongnu.org Cc: Aurelien Jarno , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Richard Henderson , Eduardo Habkost , "Michael S. Tsirkin" , =?UTF-8?q?Herv=C3=A9=20Poussineau?= , Paolo Bonzini , Bernhard Beschow Subject: [PATCH v4 04/11] hw/isa/piix4: QOM'ify PCI device creation and wiring Date: Fri, 3 Jun 2022 20:50:38 +0200 Message-Id: <20220603185045.143789-5-shentey@gmail.com> X-Mailer: git-send-email 2.36.1 In-Reply-To: <20220603185045.143789-1-shentey@gmail.com> References: <20220603185045.143789-1-shentey@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable 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=2a00:1450:4864:20::532; envelope-from=shentey@gmail.com; helo=mail-ed1-x532.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, FREEMAIL_FROM=0.001, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: pass (identity @gmail.com) X-ZM-MESSAGEID: 1654282765808100001 PCI interrupt wiring and device creation were performed in create() functions which are obsolete. Move these tasks into QOM functions to modernize the code. Signed-off-by: Bernhard Beschow Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/isa/piix4.c | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/hw/isa/piix4.c b/hw/isa/piix4.c index 18aa24424f..058bebb5e2 100644 --- a/hw/isa/piix4.c +++ b/hw/isa/piix4.c @@ -35,6 +35,7 @@ #include "hw/rtc/mc146818rtc.h" #include "hw/ide/pci.h" #include "hw/acpi/piix4.h" +#include "hw/usb/hcd-uhci.h" #include "migration/vmstate.h" #include "sysemu/reset.h" #include "sysemu/runstate.h" @@ -46,6 +47,8 @@ struct PIIX4State { qemu_irq *isa; =20 RTCState rtc; + PCIIDEState ide; + UHCIState uhci; /* Reset Control Register */ MemoryRegion rcr_mem; uint8_t rcr; @@ -205,6 +208,7 @@ static const MemoryRegionOps piix4_rcr_ops =3D { static void piix4_realize(PCIDevice *dev, Error **errp) { PIIX4State *s =3D PIIX4_PCI_DEVICE(dev); + PCIBus *pci_bus =3D pci_get_bus(dev); ISABus *isa_bus; qemu_irq *i8259_out_irq; =20 @@ -243,6 +247,21 @@ static void piix4_realize(PCIDevice *dev, Error **errp) return; } s->rtc.irq =3D isa_get_irq(ISA_DEVICE(&s->rtc), s->rtc.isairq); + + /* IDE */ + qdev_prop_set_int32(DEVICE(&s->ide), "addr", dev->devfn + 1); + if (!qdev_realize(DEVICE(&s->ide), BUS(pci_bus), errp)) { + return; + } + pci_ide_create_devs(PCI_DEVICE(&s->ide)); + + /* USB */ + qdev_prop_set_int32(DEVICE(&s->uhci), "addr", dev->devfn + 2); + if (!qdev_realize(DEVICE(&s->uhci), BUS(pci_bus), errp)) { + return; + } + + pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PI= RQS); } =20 static void piix4_init(Object *obj) @@ -250,6 +269,8 @@ static void piix4_init(Object *obj) PIIX4State *s =3D PIIX4_PCI_DEVICE(obj); =20 object_initialize_child(obj, "rtc", &s->rtc, TYPE_MC146818_RTC); + object_initialize_child(obj, "ide", &s->ide, "piix4-ide"); + object_initialize_child(obj, "uhci", &s->uhci, "piix4-usb-uhci"); } =20 static void piix4_class_init(ObjectClass *klass, void *data) @@ -293,7 +314,6 @@ type_init(piix4_register_types) =20 DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa_bus, I2CBus **smbu= s) { - PIIX4State *s; PCIDevice *pci; DeviceState *dev; int devfn =3D PCI_DEVFN(10, 0); @@ -301,15 +321,11 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **i= sa_bus, I2CBus **smbus) pci =3D pci_create_simple_multifunction(pci_bus, devfn, true, TYPE_PIIX4_PCI_DEVICE); dev =3D DEVICE(pci); - s =3D PIIX4_PCI_DEVICE(pci); + if (isa_bus) { *isa_bus =3D ISA_BUS(qdev_get_child_bus(dev, "isa.0")); } =20 - pci =3D pci_create_simple(pci_bus, devfn + 1, "piix4-ide"); - pci_ide_create_devs(pci); - - pci_create_simple(pci_bus, devfn + 2, "piix4-usb-uhci"); if (smbus) { pci =3D pci_new(devfn + 3, TYPE_PIIX4_PM); qdev_prop_set_uint32(DEVICE(pci), "smb_io_base", 0x1100); @@ -320,7 +336,5 @@ DeviceState *piix4_create(PCIBus *pci_bus, ISABus **isa= _bus, I2CBus **smbus) *smbus =3D I2C_BUS(qdev_get_child_bus(DEVICE(pci), "i2c")); } =20 - pci_bus_irqs(pci_bus, piix4_set_irq, pci_slot_get_pirq, s, PIIX_NUM_PI= RQS); - return dev; } --=20 2.36.1