From nobody Wed Nov 5 16:41:02 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1535562646208810.1574609027253; Wed, 29 Aug 2018 10:10:46 -0700 (PDT) Received: from localhost ([::1]:44166 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fv3zR-0007JX-3t for importer@patchew.org; Wed, 29 Aug 2018 13:10:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52598) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fv3wh-0005L7-CA for qemu-devel@nongnu.org; Wed, 29 Aug 2018 13:07:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fv3oW-0004Jp-Bg for qemu-devel@nongnu.org; Wed, 29 Aug 2018 12:59:31 -0400 Received: from chuckie.co.uk ([82.165.15.123]:38946 helo=s16892447.onlinehome-server.info) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fv3oW-0004JC-3o; Wed, 29 Aug 2018 12:59:28 -0400 Received: from host86-133-194-196.range86-133.btcentralplus.com ([86.133.194.196] helo=kentang.home) by s16892447.onlinehome-server.info with esmtpsa (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.76) (envelope-from ) id 1fv3oi-00046q-1t; Wed, 29 Aug 2018 17:59:41 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, qemu-ppc@nongnu.org, david@gibson.dropbear.id.au Date: Wed, 29 Aug 2018 17:59:09 +0100 Message-Id: <20180829165911.30106-6-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20180829165911.30106-1-mark.cave-ayland@ilande.co.uk> References: <20180829165911.30106-1-mark.cave-ayland@ilande.co.uk> X-SA-Exim-Connect-IP: 86.133.194.196 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk X-SA-Exim-Version: 4.2.1 (built Sun, 08 Jan 2012 02:45:44 +0000) X-SA-Exim-Scanned: Yes (on s16892447.onlinehome-server.info) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 82.165.15.123 Subject: [Qemu-devel] [PATCH 5/7] mac_oldworld: implement custom FWPathProvider X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 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: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" This enables the correct generation of bootdevice fw paths for in-built IDE and virtio-pci-blk devices suitable for OpenBIOS. Note we also set the MachineClass ignore_boot_device_suffixes property to t= rue since an additional disk node should not be added except for virtio devices. Signed-off-by: Mark Cave-Ayland --- hw/ppc/mac_oldworld.c | 58 +++++++++++++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c index c7b73e274f..9891c325a9 100644 --- a/hw/ppc/mac_oldworld.c +++ b/hw/ppc/mac_oldworld.c @@ -42,6 +42,7 @@ #include "hw/misc/macio/macio.h" #include "hw/ide.h" #include "hw/loader.h" +#include "hw/fw-path-provider.h" #include "elf.h" #include "qemu/error-report.h" #include "sysemu/kvm.h" @@ -373,6 +374,54 @@ static void ppc_heathrow_init(MachineState *machine) qemu_register_boot_set(fw_cfg_boot_set, fw_cfg); } =20 +/* + * Implementation of an interface to adjust firmware path + * for the bootindex property handling. + */ +static char *heathrow_fw_dev_path(FWPathProvider *p, BusState *bus, + DeviceState *dev) +{ + PCIDevice *pci; + IDEBus *ide_bus; + IDEState *ide_s; + MACIOIDEState *macio_ide; + + if (!strcmp(object_get_typename(OBJECT(dev)), "macio-oldworld")) { + pci =3D PCI_DEVICE(dev); + return g_strdup_printf("mac-io@%x", PCI_SLOT(pci->devfn)); + } + + if (!strcmp(object_get_typename(OBJECT(dev)), "macio-ide")) { + macio_ide =3D MACIO_IDE(dev); + return g_strdup_printf("ata-3@%x", macio_ide->addr); + } + + if (!strcmp(object_get_typename(OBJECT(dev)), "ide-drive")) { + ide_bus =3D IDE_BUS(qdev_get_parent_bus(dev)); + ide_s =3D idebus_active_if(ide_bus); + + if (ide_s->drive_kind =3D=3D IDE_CD) { + return g_strdup("cdrom"); + } + + return g_strdup("hd"); + } + + if (!strcmp(object_get_typename(OBJECT(dev)), "ide-hd")) { + return g_strdup("hd"); + } + + if (!strcmp(object_get_typename(OBJECT(dev)), "ide-cd")) { + return g_strdup("cdrom"); + } + + if (!strcmp(object_get_typename(OBJECT(dev)), "virtio-blk-device")) { + return g_strdup("disk"); + } + + return NULL; +} + static int heathrow_kvm_type(const char *arg) { /* Always force PR KVM */ @@ -382,6 +431,7 @@ static int heathrow_kvm_type(const char *arg) static void heathrow_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); + FWPathProviderClass *fwc =3D FW_PATH_PROVIDER_CLASS(oc); =20 mc->desc =3D "Heathrow based PowerMAC"; mc->init =3D ppc_heathrow_init; @@ -395,12 +445,18 @@ static void heathrow_class_init(ObjectClass *oc, void= *data) mc->kvm_type =3D heathrow_kvm_type; mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("750_v3.1"); mc->default_display =3D "std"; + mc->ignore_boot_device_suffixes =3D true; + fwc->get_dev_path =3D heathrow_fw_dev_path; } =20 static const TypeInfo ppc_heathrow_machine_info =3D { .name =3D MACHINE_TYPE_NAME("g3beige"), .parent =3D TYPE_MACHINE, - .class_init =3D heathrow_class_init + .class_init =3D heathrow_class_init, + .interfaces =3D (InterfaceInfo[]) { + { TYPE_FW_PATH_PROVIDER }, + { } + }, }; =20 static void ppc_heathrow_register_types(void) --=20 2.11.0