From nobody Fri Sep 5 22:29:16 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=eik.bme.hu Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1746141839082161.40126706962337; Thu, 1 May 2025 16:23:59 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1uAdDO-00056v-1y; Thu, 01 May 2025 19:21:14 -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 1uAdD1-0004mq-12; Thu, 01 May 2025 19:20:52 -0400 Received: from zero.eik.bme.hu ([152.66.115.2]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1uAdCx-0007He-7z; Thu, 01 May 2025 19:20:49 -0400 Received: from zero.eik.bme.hu (localhost [127.0.0.1]) by zero.eik.bme.hu (Postfix) with ESMTP id AFDE655D263; Fri, 02 May 2025 01:20:44 +0200 (CEST) Received: from zero.eik.bme.hu ([127.0.0.1]) by zero.eik.bme.hu (zero.eik.bme.hu [127.0.0.1]) (amavisd-new, port 10028) with ESMTP id Gnq_wRok2kWY; Fri, 2 May 2025 01:20:42 +0200 (CEST) Received: by zero.eik.bme.hu (Postfix, from userid 432) id B786155D25F; Fri, 02 May 2025 01:20:42 +0200 (CEST) X-Virus-Scanned: amavisd-new at eik.bme.hu Message-ID: <8c2385fcfc755ab65b76a8f2ce52d58e7b0da959.1746139668.git.balaton@eik.bme.hu> In-Reply-To: References: From: BALATON Zoltan Subject: [PATCH 10/13] hw/ppc/pegasos2: Introduce abstract superclass To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org Cc: Nicholas Piggin Date: Fri, 02 May 2025 01:20:42 +0200 (CEST) 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: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001, 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.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-bounces+importer=patchew.org@nongnu.org X-ZM-MESSAGEID: 1746141841820124100 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Rename machine state struct to PegasosMachineState as it will be used for pegasos1 too. Signed-off-by: BALATON Zoltan --- hw/ppc/pegasos2.c | 66 ++++++++++++++++++++++++----------------------- 1 file changed, 34 insertions(+), 32 deletions(-) diff --git a/hw/ppc/pegasos2.c b/hw/ppc/pegasos2.c index e3c1ee9347..f7999520e4 100644 --- a/hw/ppc/pegasos2.c +++ b/hw/ppc/pegasos2.c @@ -57,10 +57,10 @@ =20 #define BUS_FREQ_HZ 133333333 =20 -#define TYPE_PEGASOS2_MACHINE MACHINE_TYPE_NAME("pegasos2") -OBJECT_DECLARE_TYPE(Pegasos2MachineState, MachineClass, PEGASOS2_MACHINE) +#define TYPE_PEGASOS_MACHINE MACHINE_TYPE_NAME("pegasos") +OBJECT_DECLARE_SIMPLE_TYPE(PegasosMachineState, PEGASOS_MACHINE) =20 -struct Pegasos2MachineState { +struct PegasosMachineState { MachineState parent_obj; =20 PowerPCCPU *cpu; @@ -78,12 +78,12 @@ struct Pegasos2MachineState { uint64_t initrd_size; }; =20 -static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size); +static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size); =20 static void pegasos2_cpu_reset(void *opaque) { PowerPCCPU *cpu =3D opaque; - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(current_machine); + PegasosMachineState *pm =3D PEGASOS_MACHINE(current_machine); =20 cpu_reset(CPU(cpu)); cpu->env.spr[SPR_HID1] =3D 7ULL << 28; @@ -96,7 +96,7 @@ static void pegasos2_cpu_reset(void *opaque) =20 static void pegasos2_pci_irq(void *opaque, int n, int level) { - Pegasos2MachineState *pm =3D opaque; + PegasosMachineState *pm =3D opaque; =20 /* PCI interrupt lines are connected to both MV64361 and VT8231 */ qemu_set_irq(pm->mv_pirq[n], level); @@ -104,7 +104,7 @@ static void pegasos2_pci_irq(void *opaque, int n, int l= evel) } =20 /* Set up PCI interrupt routing: lines from pci.0 and pci.1 are ORed */ -static void pegasos2_setup_pci_irq(Pegasos2MachineState *pm) +static void pegasos2_setup_pci_irq(PegasosMachineState *pm) { for (int h =3D 0; h < 2; h++) { DeviceState *pd; @@ -137,7 +137,7 @@ static void pegasos2_setup_pci_irq(Pegasos2MachineState= *pm) =20 static void pegasos2_init(MachineState *machine) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); + PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); CPUPPCState *env; MemoryRegion *rom =3D g_new(MemoryRegion, 1); PCIBus *pci_bus; @@ -262,7 +262,7 @@ static void pegasos2_init(MachineState *machine) } } =20 -static uint32_t pegasos2_mv_reg_read(Pegasos2MachineState *pm, +static uint32_t pegasos2_mv_reg_read(PegasosMachineState *pm, uint32_t addr, uint32_t len) { MemoryRegion *r =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0); @@ -272,7 +272,7 @@ static uint32_t pegasos2_mv_reg_read(Pegasos2MachineSta= te *pm, return val; } =20 -static void pegasos2_mv_reg_write(Pegasos2MachineState *pm, uint32_t addr, +static void pegasos2_mv_reg_write(PegasosMachineState *pm, uint32_t addr, uint32_t len, uint32_t val) { MemoryRegion *r =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(pm->nb), 0); @@ -283,7 +283,7 @@ static void pegasos2_mv_reg_write(Pegasos2MachineState = *pm, uint32_t addr, #define PCI0_CFG_ADDR 0xcf8 #define PCI1_CFG_ADDR 0xc78 =20 -static uint32_t pegasos2_pci_config_read(Pegasos2MachineState *pm, int bus, +static uint32_t pegasos2_pci_config_read(PegasosMachineState *pm, int bus, uint32_t addr, uint32_t len) { hwaddr pcicfg =3D bus ? PCI1_CFG_ADDR : PCI0_CFG_ADDR; @@ -296,7 +296,7 @@ static uint32_t pegasos2_pci_config_read(Pegasos2Machin= eState *pm, int bus, return val; } =20 -static void pegasos2_pci_config_write(Pegasos2MachineState *pm, int bus, +static void pegasos2_pci_config_write(PegasosMachineState *pm, int bus, uint32_t addr, uint32_t len, uint32_= t val) { hwaddr pcicfg =3D bus ? PCI1_CFG_ADDR : PCI0_CFG_ADDR; @@ -311,7 +311,7 @@ static void pegasos2_superio_write(uint8_t addr, uint8_= t val) cpu_physical_memory_write(0xfe0003f1, &val, 1); } =20 -static void pegasos2_chipset_reset(Pegasos2MachineState *pm) +static void pegasos2_chipset_reset(PegasosMachineState *pm) { pegasos2_mv_reg_write(pm, 0, 4, 0x28020ff); pegasos2_mv_reg_write(pm, 0x278, 4, 0xa31fc); @@ -379,7 +379,7 @@ static void pegasos2_chipset_reset(Pegasos2MachineState= *pm) =20 static void pegasos2_machine_reset(MachineState *machine, ResetType type) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(machine); + PegasosMachineState *pm =3D PEGASOS_MACHINE(machine); void *fdt; uint32_t c[2]; uint64_t d[2]; @@ -463,7 +463,7 @@ enum pegasos2_rtas_tokens { RTAS_SYSTEM_REBOOT =3D 20, }; =20 -static target_ulong pegasos2_rtas(PowerPCCPU *cpu, Pegasos2MachineState *p= m, +static target_ulong pegasos2_rtas(PowerPCCPU *cpu, PegasosMachineState *pm, target_ulong args_real) { AddressSpace *as =3D CPU(cpu)->as; @@ -566,7 +566,7 @@ static bool pegasos2_cpu_in_nested(PowerPCCPU *cpu) =20 static void pegasos2_hypercall(PPCVirtualHypervisor *vhyp, PowerPCCPU *cpu) { - Pegasos2MachineState *pm =3D PEGASOS2_MACHINE(vhyp); + PegasosMachineState *pm =3D PEGASOS_MACHINE(vhyp); CPUPPCState *env =3D &cpu->env; =20 /* The TCG path should also be holding the BQL at this point */ @@ -629,24 +629,26 @@ static void pegasos2_machine_class_init(ObjectClass *= oc, const void *data) vmc->setprop =3D pegasos2_setprop; } =20 -static const TypeInfo pegasos2_machine_info =3D { - .name =3D TYPE_PEGASOS2_MACHINE, - .parent =3D TYPE_MACHINE, - .class_init =3D pegasos2_machine_class_init, - .instance_size =3D sizeof(Pegasos2MachineState), - .interfaces =3D (const InterfaceInfo[]) { - { TYPE_PPC_VIRTUAL_HYPERVISOR }, - { TYPE_VOF_MACHINE_IF }, - { } +static const TypeInfo pegasos_machine_types[] =3D { + { + .name =3D TYPE_PEGASOS_MACHINE, + .parent =3D TYPE_MACHINE, + .instance_size =3D sizeof(PegasosMachineState), + .abstract =3D true, + }, + { + .name =3D MACHINE_TYPE_NAME("pegasos2"), + .parent =3D TYPE_PEGASOS_MACHINE, + .class_init =3D pegasos2_machine_class_init, + .interfaces =3D (const InterfaceInfo[]) { + { TYPE_PPC_VIRTUAL_HYPERVISOR }, + { TYPE_VOF_MACHINE_IF }, + { } + }, }, }; =20 -static void pegasos2_machine_register_types(void) -{ - type_register_static(&pegasos2_machine_info); -} - -type_init(pegasos2_machine_register_types) +DEFINE_TYPES(pegasos_machine_types) =20 /* FDT creation for passing to firmware */ =20 @@ -848,7 +850,7 @@ static void *load_dtb(const char *filename, int *fdt_si= ze) return fdt; } =20 -static void *pegasos2_build_fdt(Pegasos2MachineState *pm, int *fdt_size) +static void *pegasos2_build_fdt(PegasosMachineState *pm, int *fdt_size) { FDTInfo fi; PCIBus *pci_bus; --=20 2.41.3