From nobody Wed Nov 5 18:39:28 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; dkim=fail; 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 (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1536305684697119.09003035003207; Fri, 7 Sep 2018 00:34:44 -0700 (PDT) Received: from localhost ([::1]:37114 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyBHm-0001VA-Fa for importer@patchew.org; Fri, 07 Sep 2018 03:34:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fyBFU-0007V2-S9 for qemu-devel@nongnu.org; Fri, 07 Sep 2018 03:32:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fyBFT-000559-GS for qemu-devel@nongnu.org; Fri, 07 Sep 2018 03:32:12 -0400 Received: from ozlabs.org ([203.11.71.1]:43347) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fyBFS-00053q-RF; Fri, 07 Sep 2018 03:32:11 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 4268Jz0yWbz9sjD; Fri, 7 Sep 2018 17:32:02 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1536305523; bh=Ve7v6oOdDo2E/9P/dJQNTOEcC4DCGqAAtwn3e1DxR4E=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FYg+hYqfCTIGYzdo73Sf2p24syJ6LFsI36xoLAjOxMFIKB8w2wbprC7vPNPjuZ/K0 v3JZ0lFGYwDzTljOIlZU5d2mLKv6bAj8JV4zon4jtwQepQ/CU5z/QxXwBRwHRLk1Ey Sn3iDhBNRmAzD22miOiCgKhf5IPmIvhPZkgDeIbc= From: David Gibson To: peter.maydell@linaro.org Date: Fri, 7 Sep 2018 17:31:51 +1000 Message-Id: <20180907073155.26200-11-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180907073155.26200-1-david@gibson.dropbear.id.au> References: <20180907073155.26200-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 10/14] mac_newworld: 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: , Cc: lvivier@redhat.com, mark.cave-ayland@ilande.co.uk, qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Mark Cave-Ayland 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 Signed-off-by: David Gibson --- hw/ppc/mac_newworld.c | 58 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c index 325013f563..a630cb81cd 100644 --- a/hw/ppc/mac_newworld.c +++ b/hw/ppc/mac_newworld.c @@ -64,6 +64,7 @@ #include "hw/ppc/openpic.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" @@ -521,6 +522,54 @@ static void ppc_core99_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 *core99_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-newworld")) { + 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 core99_kvm_type(const char *arg) { /* Always force PR KVM */ @@ -530,6 +579,7 @@ static int core99_kvm_type(const char *arg) static void core99_machine_class_init(ObjectClass *oc, void *data) { MachineClass *mc =3D MACHINE_CLASS(oc); + FWPathProviderClass *fwc =3D FW_PATH_PROVIDER_CLASS(oc); =20 mc->desc =3D "Mac99 based PowerMAC"; mc->init =3D ppc_core99_init; @@ -543,6 +593,8 @@ static void core99_machine_class_init(ObjectClass *oc, = void *data) #else mc->default_cpu_type =3D POWERPC_CPU_TYPE_NAME("7400_v2.9"); #endif + mc->ignore_boot_device_suffixes =3D true; + fwc->get_dev_path =3D core99_fw_dev_path; } =20 static char *core99_get_via_config(Object *obj, Error **errp) @@ -599,7 +651,11 @@ static const TypeInfo core99_machine_info =3D { .parent =3D TYPE_MACHINE, .class_init =3D core99_machine_class_init, .instance_init =3D core99_instance_init, - .instance_size =3D sizeof(Core99MachineState) + .instance_size =3D sizeof(Core99MachineState), + .interfaces =3D (InterfaceInfo[]) { + { TYPE_FW_PATH_PROVIDER }, + { } + }, }; =20 static void mac_machine_register_types(void) --=20 2.17.1