From nobody Wed Nov 27 19:43:37 2024 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=kernel.org ARC-Seal: i=1; a=rsa-sha256; t=1697313502; cv=none; d=zohomail.com; s=zohoarc; b=WJtoqBK2b4MMsSa0ZvhNmEjjuk/L2eS2VWH/PuqDAwpLP3FWXD626sFdVg5hfXyRu4VzKxQ/7k+XmYRG24zHnjmgrRr88T6pH+B0ilWdONQshOEqFD9uj0KSt7qFDilsWrIlSe0qobjyw6ZBuFs3RWSil99uGuln8mDZ0hm7bV8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1697313502; h=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=vk61NZagwqok4pAde8bVrg6dzN6qm9Qxtr7XsjZGEZA=; b=DJuX/CpNcX9+Jw4aNPtvyMR9OlSCVrUFvp2vg09InVjZOB1EZhGY0OQ6Fjy4ESf4oN3k/8zkaQclbwgAoj+hzQ5UeIib/uLJzR+9XFAcqDW3LP+qqRITlkAh9fIL8lCOWX8vWupb+quZCotUntdHUEF/y2o/KY8y8q3qiSfRlTg= 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 1697313502379856.3011381975847; Sat, 14 Oct 2023 12:58:22 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1qrkli-00041F-MT; Sat, 14 Oct 2023 15:57:51 -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 1qrkle-0003yD-AE for qemu-devel@nongnu.org; Sat, 14 Oct 2023 15:57:46 -0400 Received: from ams.source.kernel.org ([145.40.68.75]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1qrklb-0004fE-OW for qemu-devel@nongnu.org; Sat, 14 Oct 2023 15:57:45 -0400 Received: from smtp.kernel.org (transwarp.subspace.kernel.org [100.75.92.58]) by ams.source.kernel.org (Postfix) with ESMTP id C7C7FB80B74; Sat, 14 Oct 2023 19:57:39 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 481C0C433C9; Sat, 14 Oct 2023 19:57:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1697313459; bh=rfJauSzi5+tEvjuOKdar2ThVVLGAlGs2JK1Zco781kU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ry7AMWQvzkdsNP/8jkvG/dM2bTlgSNAEVR16ibZ41i5JPOYch7UWvPUeWLHfYuQB/ FbT0O12AlJ7lT8e9NFCtzThYzMg8ww2VnsitxIadU2HOjv6B7vh78zCCOl8sxS2Dl4 mP3jaTD6WQUUli92D/2tRLOGyzjLW5bkrnByFH6VNLgWZARzVc2q69ihKz3LWTysJM edp6QrzJFb2x+weLrAz09muvorLXTAI9HAZpfpheS636TLgnO0StWZF8I5BAz2ot7L qV6B3AI9ZTyGXYfATL/Bo3v3ssFsEUcEQiV6MQsNhhoIOdA1LlvhNRJIe0ksahg5Jw s4YEY57vYWIXg== From: deller@kernel.org To: qemu-devel@nongnu.org Cc: Richard Henderson , Helge Deller Subject: [PATCH 11/12] hw/hppa: Split out machine creation Date: Sat, 14 Oct 2023 21:57:18 +0200 Message-ID: <20231014195719.151397-12-deller@kernel.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231014195719.151397-1-deller@kernel.org> References: <20231014195719.151397-1-deller@kernel.org> MIME-Version: 1.0 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=145.40.68.75; envelope-from=deller@kernel.org; helo=ams.source.kernel.org X-Spam_score_int: -43 X-Spam_score: -4.4 X-Spam_bar: ---- X-Spam_report: (-4.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, 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.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-ZohoMail-DKIM: pass (identity @kernel.org) X-ZM-MESSAGEID: 1697313504384100009 Content-Type: text/plain; charset="utf-8" From: Helge Deller This is a preparation patch to allow the creation of additional hppa machine. It splits out the creation of the machine into a - machine_HP_common_init_cpus(), and a - machine_HP_common_init_tail() function. This will allow to reuse the basic functions which are common to all parisc machines. Signed-off-by: Helge Deller --- hw/hppa/machine.c | 170 ++++++++++++++++++++++++++-------------------- 1 file changed, 98 insertions(+), 72 deletions(-) diff --git a/hw/hppa/machine.c b/hw/hppa/machine.c index 299b5bc95c..71087a3f2f 100644 --- a/hw/hppa/machine.c +++ b/hw/hppa/machine.c @@ -23,6 +23,7 @@ #include "hw/net/lasi_82596.h" #include "hw/nmi.h" #include "hw/pci/pci.h" +#include "hw/pci/pci_device.h" #include "hw/pci-host/dino.h" #include "hw/misc/lasi.h" #include "hppa_hardware.h" @@ -38,6 +39,7 @@ #define enable_lasi_lan() 0 =20 static PCIBus *pci_bus; +static DeviceState *lasi_dev; =20 static void hppa_powerdown_req(Notifier *n, void *opaque) { @@ -251,29 +253,20 @@ static DinoState *dino_init(MemoryRegion *addr_space) return DINO_PCI_HOST_BRIDGE(dev); } =20 -static void machine_hppa_init(MachineState *machine) +/* + * Step 1: Create CPUs and Memory + */ +static void machine_HP_common_init_cpus(MachineState *machine) { - const char *kernel_filename =3D machine->kernel_filename; - const char *kernel_cmdline =3D machine->kernel_cmdline; - const char *initrd_filename =3D machine->initrd_filename; - MachineClass *mc =3D MACHINE_GET_CLASS(machine); - DeviceState *dev, *dino_dev, *lasi_dev; - PCIBus *pci_bus; - ISABus *isa_bus; - char *firmware_filename; - uint64_t firmware_low, firmware_high; - long size; - uint64_t kernel_entry =3D 0, kernel_low, kernel_high; MemoryRegion *addr_space =3D get_system_memory(); - MemoryRegion *rom_region; MemoryRegion *cpu_region; long i; unsigned int smp_cpus =3D machine->smp.cpus; - SysBusDevice *s; + char *name; =20 /* Create CPUs. */ for (i =3D 0; i < smp_cpus; i++) { - char *name =3D g_strdup_printf("cpu%ld-io-eir", i); + name =3D g_strdup_printf("cpu%ld-io-eir", i); cpu[i] =3D HPPA_CPU(cpu_create(machine->cpu_type)); =20 cpu_region =3D g_new(MemoryRegion, 1); @@ -296,45 +289,27 @@ static void machine_hppa_init(MachineState *machine) exit(EXIT_FAILURE); } memory_region_add_subregion_overlap(addr_space, 0, machine->ram, -1); +} =20 - - /* Init Lasi chip */ - lasi_dev =3D DEVICE(lasi_init()); - memory_region_add_subregion(addr_space, LASI_HPA, - sysbus_mmio_get_region( - SYS_BUS_DEVICE(lasi_dev), 0)); - - /* Init Dino (PCI host bus chip). */ - dino_dev =3D DEVICE(dino_init(addr_space)); - memory_region_add_subregion(addr_space, DINO_HPA, - sysbus_mmio_get_region( - SYS_BUS_DEVICE(dino_dev), 0)); - pci_bus =3D PCI_BUS(qdev_get_child_bus(dino_dev, "pci")); - assert(pci_bus); - - /* Create ISA bus. */ - isa_bus =3D hppa_isa_bus(); - assert(isa_bus); - - /* Realtime clock, used by firmware for PDC_TOD call. */ - mc146818_rtc_init(isa_bus, 2000, NULL); - - /* Serial ports: Lasi and Dino use a 7.272727 MHz clock. */ - serial_mm_init(addr_space, LASI_UART_HPA + 0x800, 0, - qdev_get_gpio_in(lasi_dev, LASI_IRQ_UART_HPA), 7272727 / 16, - serial_hd(0), DEVICE_BIG_ENDIAN); - - serial_mm_init(addr_space, DINO_UART_HPA + 0x800, 0, - qdev_get_gpio_in(dino_dev, DINO_IRQ_RS232INT), 7272727 / 16, - serial_hd(1), DEVICE_BIG_ENDIAN); - - /* Parallel port */ - parallel_mm_init(addr_space, LASI_LPT_HPA + 0x800, 0, - qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA), - parallel_hds[0]); - - /* fw_cfg configuration interface */ - create_fw_cfg(machine); +/* + * Last creation step: Add SCSI discs, NICs, graphics & load firmware + */ +static void machine_HP_common_init_tail(MachineState *machine) +{ + const char *kernel_filename =3D machine->kernel_filename; + const char *kernel_cmdline =3D machine->kernel_cmdline; + const char *initrd_filename =3D machine->initrd_filename; + MachineClass *mc =3D MACHINE_GET_CLASS(machine); + DeviceState *dev; + char *firmware_filename; + uint64_t firmware_low, firmware_high; + long size; + uint64_t kernel_entry =3D 0, kernel_low, kernel_high; + MemoryRegion *addr_space =3D get_system_memory(); + MemoryRegion *rom_region; + long i; + unsigned int smp_cpus =3D machine->smp.cpus; + SysBusDevice *s; =20 /* SCSI disk setup. */ dev =3D DEVICE(pci_create_simple(pci_bus, -1, "lsi53c895a")); @@ -362,21 +337,12 @@ static void machine_hppa_init(MachineState *machine) } } =20 - /* PS/2 Keyboard/Mouse */ - dev =3D qdev_new(TYPE_LASIPS2); - sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); - sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, - qdev_get_gpio_in(lasi_dev, LASI_IRQ_PS2KBD_HPA)); - memory_region_add_subregion(addr_space, LASI_PS2KBD_HPA, - sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), - 0)); - memory_region_add_subregion(addr_space, LASI_PS2KBD_HPA + 0x100, - sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), - 1)); - /* register power switch emulation */ qemu_register_powerdown_notifier(&hppa_system_powerdown_notifier); =20 + /* fw_cfg configuration interface */ + create_fw_cfg(machine); + /* Load firmware. Given that this is not "real" firmware, but one explicitly written for the emulation, we might as well load it directly from an ELF image. */ @@ -494,6 +460,66 @@ static void machine_hppa_init(MachineState *machine) cpu[0]->env.gr[19] =3D FW_CFG_IO_BASE; } =20 +/* + * Create HP B160L workstation + */ +static void machine_HP_B160L_init(MachineState *machine) +{ + DeviceState *dev, *dino_dev; + MemoryRegion *addr_space =3D get_system_memory(); + ISABus *isa_bus; + + /* Create CPUs and RAM. */ + machine_HP_common_init_cpus(machine); + + /* Init Lasi chip */ + lasi_dev =3D DEVICE(lasi_init()); + memory_region_add_subregion(addr_space, LASI_HPA, + sysbus_mmio_get_region( + SYS_BUS_DEVICE(lasi_dev), 0)); + + /* Init Dino (PCI host bus chip). */ + dino_dev =3D DEVICE(dino_init(addr_space)); + memory_region_add_subregion(addr_space, DINO_HPA, + sysbus_mmio_get_region( + SYS_BUS_DEVICE(dino_dev), 0)); + pci_bus =3D PCI_BUS(qdev_get_child_bus(dino_dev, "pci")); + assert(pci_bus); + + /* Create ISA bus, needed for PS/2 kbd/mouse port emulation */ + isa_bus =3D hppa_isa_bus(); + assert(isa_bus); + + /* Serial ports: Lasi and Dino use a 7.272727 MHz clock. */ + serial_mm_init(addr_space, LASI_UART_HPA + 0x800, 0, + qdev_get_gpio_in(lasi_dev, LASI_IRQ_UART_HPA), 7272727 / 16, + serial_hd(0), DEVICE_BIG_ENDIAN); + + serial_mm_init(addr_space, DINO_UART_HPA + 0x800, 0, + qdev_get_gpio_in(dino_dev, DINO_IRQ_RS232INT), 7272727 / 16, + serial_hd(1), DEVICE_BIG_ENDIAN); + + /* Parallel port */ + parallel_mm_init(addr_space, LASI_LPT_HPA + 0x800, 0, + qdev_get_gpio_in(lasi_dev, LASI_IRQ_LAN_HPA), + parallel_hds[0]); + + /* PS/2 Keyboard/Mouse */ + dev =3D qdev_new(TYPE_LASIPS2); + sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal); + sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, + qdev_get_gpio_in(lasi_dev, LASI_IRQ_PS2KBD_HPA)); + memory_region_add_subregion(addr_space, LASI_PS2KBD_HPA, + sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), + 0)); + memory_region_add_subregion(addr_space, LASI_PS2KBD_HPA + 0x100, + sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), + 1)); + + /* Add SCSI discs, NICs, graphics & load firmware */ + machine_HP_common_init_tail(machine); +} + static void hppa_machine_reset(MachineState *ms, ShutdownCause reason) { unsigned int smp_cpus =3D ms->smp.cpus; @@ -542,14 +568,14 @@ static void hppa_nmi(NMIState *n, int cpu_index, Erro= r **errp) } } =20 -static void hppa_machine_init_class_init(ObjectClass *oc, void *data) +static void HP_B160L_machine_init_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); NMIClass *nc =3D NMI_CLASS(oc); =20 - mc->desc =3D "HPPA B160L machine"; + mc->desc =3D "HP B160L workstation"; mc->default_cpu_type =3D TYPE_HPPA_CPU; - mc->init =3D machine_hppa_init; + mc->init =3D machine_HP_B160L_init; mc->reset =3D hppa_machine_reset; mc->block_default_type =3D IF_SCSI; mc->max_cpus =3D HPPA_MAX_CPUS; @@ -563,10 +589,10 @@ static void hppa_machine_init_class_init(ObjectClass = *oc, void *data) nc->nmi_monitor_handler =3D hppa_nmi; } =20 -static const TypeInfo hppa_machine_init_typeinfo =3D { - .name =3D MACHINE_TYPE_NAME("hppa"), +static const TypeInfo HP_B160L_machine_init_typeinfo =3D { + .name =3D MACHINE_TYPE_NAME("B160L"), .parent =3D TYPE_MACHINE, - .class_init =3D hppa_machine_init_class_init, + .class_init =3D HP_B160L_machine_init_class_init, .interfaces =3D (InterfaceInfo[]) { { TYPE_NMI }, { } @@ -575,7 +601,7 @@ static const TypeInfo hppa_machine_init_typeinfo =3D { =20 static void hppa_machine_init_register_types(void) { - type_register_static(&hppa_machine_init_typeinfo); + type_register_static(&HP_B160L_machine_init_typeinfo); } =20 type_init(hppa_machine_init_register_types) --=20 2.41.0