From nobody Wed Apr 8 04:39:42 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=reject dis=none) header.from=yodel.dev ARC-Seal: i=1; a=rsa-sha256; t=1773182032; cv=none; d=zohomail.com; s=zohoarc; b=YDxx17/H5Viomqu3G7lEcKVX1rbm8Nj35I65IqPeZxZS2iQEG/NSnpOR+LPGD65tB1iGDzV7wHNVUkC7z323acT7qjKiQgNNtSgvxs/pr9YWL5aon0Rzatx7gARZ6hAzEIZekt/NIvDDieNbQ24H571cueM3IqMrlsovJv1caho= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773182032; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=RyVAKJLMo0aGuRn7813OVY/29sKqnOGraCtDLeWGLNE=; b=FOWszxiY8CtY7ABaYpjdsvIKAfH/RW+qEu8mxJiK8JXiTCWpRpvhpyFdJIiJSdBTueMmAuZtS22Dk0s+we+pwYjuhgzRoXyRXd1w2Z/kmKDf628LMhOyJt5+oQptU9Sz0hycQWXO6FylYGqFoiRFEqEXORuoAbSScwBaqKbiveA= 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=reject dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1773182032816829.7745469218808; Tue, 10 Mar 2026 15:33:52 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1w05d2-0001Io-Uh; Tue, 10 Mar 2026 18:32:40 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1w05cu-0001Fv-NR for qemu-devel@nongnu.org; Tue, 10 Mar 2026 18:32:34 -0400 Received: from v512.v5f06b487.use4.send.mailgun.net ([143.55.232.12]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1w05cr-00073c-9m for qemu-devel@nongnu.org; Tue, 10 Mar 2026 18:32:32 -0400 Received: from mail.yodel.dev (mail.yodel.dev [35.209.39.246]) by ef8cb5a096bd0b111214fe5b7167cad5f7917c3de0449a8d432d9c13c6c82cb5 with SMTP id 69b09bf5026b9427582cbc13; Tue, 10 Mar 2026 22:32:21 GMT X-Mailgun-Sid: WyI4ZDFlNiIsInFlbXUtZGV2ZWxAbm9uZ251Lm9yZyIsIjk3NjA3ZSJd X-Mailgun-Sending-Ip: 143.55.232.12 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yodel.dev; s=rsa2048; t=1773181941; bh=RyVAKJLMo0aGuRn7813OVY/29sKqnOGraCtDLeWGLNE=; h=X-Mailgun-Dkim:From:Date:Subject:MIME-Version:Content-Type: Content-Transfer-Encoding:Message-Id:References:In-Reply-To:To:Cc: X-Developer-Signature:X-Developer-Key:From:Reply-to:Subject:Date: Message-id:To:Cc:Mime-version:Content-type: Content-transfer-encoding:In-reply-to:References; b=UcznkTtFzyqtnembeK67LuDN3PcwvImRqjSWchU/RJeyyqMZUg99ffxTMCiLbihq4 iS5BW6XSgBiBxQMBAF3MJyLx8OFcrLdLHHCYN2oqRPENEkqixZ5/42nLVUeAS6eBDF 6xyxrh+NPU+sr1y9SUFP7pepBcic9+1UZApK3CL0fBWTPL/RmzALXDirjJNU1TlmAT tude8J68qWqby5h5ptkWlV66jxtYyUnPINWWnFLpHHTfBADlhpc3lVzw3/5slduJaO A4ue+bembmOEhUfcRDfTYdl6wblSYHuibMRWG6IXRKkx9w2J5JcodYyILfi9FWI1SG nQisK1ID7R/Ww== X-Mailgun-Dkim: no X-Mailgun-Dkim: no From: Yodel Eldar Date: Tue, 10 Mar 2026 17:31:47 -0500 Subject: [PATCH 07/15] hw/alpha: Use QOM composition for the Typhoon chipset MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-MS-Reactions: disallow Message-Id: <20260310-qomify-alpha-v1-7-4375b00a85ff@yodel.dev> References: <20260310-qomify-alpha-v1-0-4375b00a85ff@yodel.dev> In-Reply-To: <20260310-qomify-alpha-v1-0-4375b00a85ff@yodel.dev> To: qemu-devel@nongnu.org Cc: Richard Henderson , Yodel Eldar X-Developer-Signature: v=1; a=openpgp-sha256; l=5491; i=yodel.eldar@yodel.dev; h=from:subject:message-id; bh=t9rEAymgy1ah9FBlM7UtLVNH7ETZR6oaCjVJ6+nJg6U=; b=owGbwMvMwCU29Z3/drNU3zWMp9WSGDI3zP5oXHqhdY+n89cLC8TfV9/gY0xYNPfedPe3c9ZpH zT918O7raOUhUGMi0FWTJHl8lmJsw65u7vSVv64DzOHlQlkCAMXpwBMxOonI8P86e6f97yvOqHj Vmr69VWs17/uoEaZ7MWPbhVf9Zm/56gLI8PVVY5fLrH1RpUfETv86dsEtRNrp5u8e7+24IwfT37 a//9cAA== X-Developer-Key: i=yodel.eldar@yodel.dev; a=openpgp; fpr=D3CD18CD406DBB8A66A9F8DF95EE4FB736654DAC 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=143.55.232.12; envelope-from=bounce+0e9322.97607e-qemu-devel=nongnu.org@yodel.dev; helo=v512.v5f06b487.use4.send.mailgun.net X-Spam_score_int: 10 X-Spam_score: 1.0 X-Spam_bar: + X-Spam_report: (1.0 / 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, HELO_STATIC_HOST=-0.001, RCVD_IN_BL_SPAMCOP_NET=1.347, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.819, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.903, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=no autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: qemu development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @yodel.dev) X-ZM-MESSAGEID: 1773182033848154100 Export the QOM declaration of TyphoonState by moving it out of hw/alpha/typhoon.c into hw/alpha/alpha_sys.h. Keep its definition encapsulated. Define ClipperMachineState with a TyphoonState member. Move the instantiation of Typhoon out of typhoon_init() into the Clipper machine and add it as a QOM child object of Clipper. For now, add TyphoonState pointer as a parameter of typhoon_init(). Note: Eventually, typhoon_init() will be split into Typhoon's instance_init and realize hooks; this is an intermediate commit to that end. Signed-off-by: Yodel Eldar --- hw/alpha/alpha_sys.h | 4 +++- hw/alpha/dp264.c | 31 ++++++++++++++++++++++++++++--- hw/alpha/typhoon.c | 12 +++--------- 3 files changed, 34 insertions(+), 13 deletions(-) diff --git a/hw/alpha/alpha_sys.h b/hw/alpha/alpha_sys.h index 6e6691d116..247a52b776 100644 --- a/hw/alpha/alpha_sys.h +++ b/hw/alpha/alpha_sys.h @@ -8,9 +8,11 @@ #include "hw/core/boards.h" #include "hw/intc/i8259.h" =20 +#define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost" +OBJECT_DECLARE_SIMPLE_TYPE(TyphoonState, TYPHOON_PCI_HOST_BRIDGE) =20 PCIBus *typhoon_init(MemoryRegion *, qemu_irq *, qemu_irq *, AlphaCPU *[4], - pci_map_irq_fn, uint8_t devfn_min); + pci_map_irq_fn, uint8_t devfn_min, TyphoonState *); =20 /* alpha_pci.c. */ extern const MemoryRegionOps alpha_pci_ignore_ops; diff --git a/hw/alpha/dp264.c b/hw/alpha/dp264.c index b2ef423f93..c9d639eb7b 100644 --- a/hw/alpha/dp264.c +++ b/hw/alpha/dp264.c @@ -18,6 +18,15 @@ #include "hw/isa/superio.h" #include "qemu/datadir.h" =20 +#define TYPE_CLIPPER_MACHINE MACHINE_TYPE_NAME("clipper") +OBJECT_DECLARE_SIMPLE_TYPE(ClipperMachineState, CLIPPER_MACHINE) + +struct ClipperMachineState { + MachineState parent_obj; + + TyphoonState *typhoon; +}; + static uint64_t cpu_alpha_superpage_to_phys(void *opaque, uint64_t addr) { if (((addr >> 41) & 3) =3D=3D 2) { @@ -46,6 +55,7 @@ static int clipper_pci_map_irq(PCIDevice *d, int irq_num) =20 static void clipper_init(MachineState *machine) { + ClipperMachineState *cms =3D CLIPPER_MACHINE(machine); ram_addr_t ram_size =3D machine->ram_size; const char *kernel_filename =3D machine->kernel_filename; const char *kernel_cmdline =3D machine->kernel_cmdline; @@ -64,6 +74,11 @@ static void clipper_init(MachineState *machine) uint64_t kernel_entry, kernel_low, kernel_high; unsigned int smp_cpus =3D machine->smp.cpus; =20 + Object * const typhoon_obj =3D object_new(TYPE_TYPHOON_PCI_HOST_BRIDGE= ); + TyphoonState * const typhoon =3D TYPHOON_PCI_HOST_BRIDGE(typhoon_obj); + cms->typhoon =3D typhoon; + object_property_add_child(OBJECT(machine), "typhoon", typhoon_obj); + /* Create up to 4 cpus. */ memset(cpus, 0, sizeof(cpus)); for (i =3D 0; i < smp_cpus; ++i) { @@ -93,7 +108,7 @@ static void clipper_init(MachineState *machine) * the minimum PCI device IdSel is 1. */ pci_bus =3D typhoon_init(machine->ram, &isa_irq, &rtc_irq, cpus, - clipper_pci_map_irq, PCI_DEVFN(1, 0)); + clipper_pci_map_irq, PCI_DEVFN(1, 0), typhoon); =20 /* * Init the PCI -> ISA bridge. @@ -218,8 +233,9 @@ static void clipper_init(MachineState *machine) } } =20 -static void clipper_machine_init(MachineClass *mc) +static void clipper_machine_init(ObjectClass *oc, const void *data) { + MachineClass *mc =3D MACHINE_CLASS(oc); mc->desc =3D "Alpha DP264/CLIPPER"; mc->init =3D clipper_init; mc->block_default_type =3D IF_IDE; @@ -230,4 +246,13 @@ static void clipper_machine_init(MachineClass *mc) mc->default_nic =3D "e1000"; } =20 -DEFINE_MACHINE("clipper", clipper_machine_init) +static const TypeInfo clipper_types[] =3D { + { + .name =3D TYPE_CLIPPER_MACHINE, + .parent =3D TYPE_MACHINE, + .instance_size =3D sizeof(ClipperMachineState), + .class_init =3D clipper_machine_init, + }, +}; + +DEFINE_TYPES(clipper_types); diff --git a/hw/alpha/typhoon.c b/hw/alpha/typhoon.c index 5789829818..b0eb4e415c 100644 --- a/hw/alpha/typhoon.c +++ b/hw/alpha/typhoon.c @@ -18,7 +18,6 @@ #include "hw/core/qdev-properties.h" =20 =20 -#define TYPE_TYPHOON_PCI_HOST_BRIDGE "typhoon-pcihost" #define TYPE_TYPHOON_IOMMU_MEMORY_REGION "typhoon-iommu-memory-region" =20 typedef struct TyphoonCchip { @@ -50,8 +49,6 @@ typedef struct TyphoonPchip { TyphoonWindow win[4]; } TyphoonPchip; =20 -OBJECT_DECLARE_SIMPLE_TYPE(TyphoonState, TYPHOON_PCI_HOST_BRIDGE) - struct TyphoonState { PCIHostState parent_obj; =20 @@ -836,18 +833,15 @@ static void typhoon_alarm_timer(void *opaque) =20 PCIBus *typhoon_init(MemoryRegion *ram, qemu_irq *p_isa_irq, qemu_irq *p_rtc_irq, AlphaCPU *cpus[4], - pci_map_irq_fn sys_map_irq, uint8_t devfn_min) + pci_map_irq_fn sys_map_irq, uint8_t devfn_min, + TyphoonState *s) { MemoryRegion *addr_space =3D get_system_memory(); - DeviceState *dev; - TyphoonState *s; + DeviceState *dev =3D DEVICE(s); PCIHostState *phb; PCIBus *b; int i; =20 - dev =3D qdev_new(TYPE_TYPHOON_PCI_HOST_BRIDGE); - - s =3D TYPHOON_PCI_HOST_BRIDGE(dev); phb =3D PCI_HOST_BRIDGE(dev); =20 s->cchip.misc =3D 0x800000000ull; /* Revision: Typhoon. */ --=20 2.53.0