All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices
@ 2018-08-29 16:59 Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 1/7] macio: move MACIOIDEState type declarations to macio.h Mark Cave-Ayland
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2018-08-29 16:59 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, david

This patchset is the QEMU counterpart to the patches posted on the OpenBIOS
list at https://mail.coreboot.org/pipermail/openbios/2018-August/010422.html
which generate correct fw paths for the Mac Old World and New World machines.

With these patches applied QEMU generates the correct fw paths for both the
in-built macio IDE and virtio-blk-pci devices enabling support for bootindex
and most importantly with an updated OpenBIOS, allowing boot from
virtio-pci-blk devices.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>


Mark Cave-Ayland (7):
  macio: move MACIOIDEState type declarations to macio.h
  macio: add macio bus to help with fw path generation
  macio: add addr property to macio IDE object
  grackle: set device fw_name and address for correct fw path generation
  mac_oldworld: implement custom FWPathProvider
  uninorth: add ofw-addr property to allow correct fw path generation
  mac_newworld: implement custom FWPathProvider

 hw/ide/macio.c                 |  2 ++
 hw/misc/macio/macio.c          | 42 ++++++++++++++++++++++--------
 hw/pci-host/grackle.c          | 17 ++++++++++++
 hw/pci-host/uninorth.c         | 16 ++++++++++++
 hw/ppc/mac.h                   | 26 -------------------
 hw/ppc/mac_newworld.c          | 59 +++++++++++++++++++++++++++++++++++++++++-
 hw/ppc/mac_oldworld.c          | 59 +++++++++++++++++++++++++++++++++++++++++-
 include/hw/misc/macio/macio.h  | 37 ++++++++++++++++++++++++++
 include/hw/pci-host/uninorth.h |  1 +
 9 files changed, 220 insertions(+), 39 deletions(-)

-- 
2.11.0

^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 1/7] macio: move MACIOIDEState type declarations to macio.h
  2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
@ 2018-08-29 16:59 ` Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 2/7] macio: add macio bus to help with fw path generation Mark Cave-Ayland
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2018-08-29 16:59 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, david

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/macio.c                |  1 +
 hw/ppc/mac.h                  | 26 --------------------------
 include/hw/misc/macio/macio.h | 26 ++++++++++++++++++++++++++
 3 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index d3a85cba3b..f23961e241 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -26,6 +26,7 @@
 #include "hw/hw.h"
 #include "hw/ppc/mac.h"
 #include "hw/ppc/mac_dbdma.h"
+#include "hw/misc/macio/macio.h"
 #include "sysemu/block-backend.h"
 #include "sysemu/dma.h"
 
diff --git a/hw/ppc/mac.h b/hw/ppc/mac.h
index 41fd289e81..a741300ac9 100644
--- a/hw/ppc/mac.h
+++ b/hw/ppc/mac.h
@@ -86,32 +86,6 @@ typedef struct Core99MachineState {
     uint8_t via_config;
 } Core99MachineState;
 
-/* MacIO */
-#define TYPE_MACIO_IDE "macio-ide"
-#define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
-
-typedef struct MACIOIDEState {
-    /*< private >*/
-    SysBusDevice parent_obj;
-    /*< public >*/
-    uint32_t channel;
-    qemu_irq real_ide_irq;
-    qemu_irq real_dma_irq;
-    qemu_irq ide_irq;
-    qemu_irq dma_irq;
-
-    MemoryRegion mem;
-    IDEBus bus;
-    IDEDMA dma;
-    void *dbdma;
-    bool dma_active;
-    uint32_t timing_reg;
-    uint32_t irq_reg;
-} MACIOIDEState;
-
-void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table);
-void macio_ide_register_dma(MACIOIDEState *ide);
-
 /* Grackle PCI */
 #define TYPE_GRACKLE_PCI_HOST_BRIDGE "grackle-pcihost"
 
diff --git a/include/hw/misc/macio/macio.h b/include/hw/misc/macio/macio.h
index cfaa145500..0c3964ec12 100644
--- a/include/hw/misc/macio/macio.h
+++ b/include/hw/misc/macio/macio.h
@@ -34,6 +34,32 @@
 #include "hw/ppc/mac_dbdma.h"
 #include "hw/ppc/openpic.h"
 
+/* MacIO IDE */
+#define TYPE_MACIO_IDE "macio-ide"
+#define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
+
+typedef struct MACIOIDEState {
+    /*< private >*/
+    SysBusDevice parent_obj;
+    /*< public >*/
+    uint32_t channel;
+    qemu_irq real_ide_irq;
+    qemu_irq real_dma_irq;
+    qemu_irq ide_irq;
+    qemu_irq dma_irq;
+
+    MemoryRegion mem;
+    IDEBus bus;
+    IDEDMA dma;
+    void *dbdma;
+    bool dma_active;
+    uint32_t timing_reg;
+    uint32_t irq_reg;
+} MACIOIDEState;
+
+void macio_ide_init_drives(MACIOIDEState *ide, DriveInfo **hd_table);
+void macio_ide_register_dma(MACIOIDEState *ide);
+
 #define TYPE_MACIO "macio"
 #define MACIO(obj) OBJECT_CHECK(MacIOState, (obj), TYPE_MACIO)
 
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 2/7] macio: add macio bus to help with fw path generation
  2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 1/7] macio: move MACIOIDEState type declarations to macio.h Mark Cave-Ayland
@ 2018-08-29 16:59 ` Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 3/7] macio: add addr property to macio IDE object Mark Cave-Ayland
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2018-08-29 16:59 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, david

As the in-built IDE controller is attached to the macio bus then we should also
model this the same in QEMU to aid fw path generation.

Note that all existing macio devices are moved onto the new macio bus so that
the qdev tree accurately reflects the real hardware.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/misc/macio/macio.c         | 37 ++++++++++++++++++++++++++++---------
 include/hw/misc/macio/macio.h | 10 ++++++++++
 2 files changed, 38 insertions(+), 9 deletions(-)

diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 52aa3775f4..229bfddb90 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -90,6 +90,15 @@ static void macio_bar_setup(MacIOState *s)
     macio_escc_legacy_setup(s);
 }
 
+static void macio_init_child_obj(MacIOState *s, const char *childname,
+                                 void *child, size_t childsize,
+                                 const char *childtype)
+{
+    object_initialize_child(OBJECT(s), childname, child, childsize, childtype,
+                            &error_abort, NULL);
+    qdev_set_parent_bus(DEVICE(child), BUS(&s->macio_bus));
+}
+
 static void macio_common_realize(PCIDevice *d, Error **errp)
 {
     MacIOState *s = MACIO(d);
@@ -211,7 +220,7 @@ static void macio_init_ide(MacIOState *s, MACIOIDEState *ide, size_t ide_size,
 {
     gchar *name = g_strdup_printf("ide[%i]", index);
 
-    sysbus_init_child_obj(OBJECT(s), name, ide, ide_size, TYPE_MACIO_IDE);
+    macio_init_child_obj(s, name, ide, ide_size, TYPE_MACIO_IDE);
     memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) * 0x1000),
                                 &ide->mem);
     g_free(name);
@@ -229,7 +238,7 @@ static void macio_oldworld_init(Object *obj)
                              qdev_prop_allow_set_link_before_realize,
                              0, NULL);
 
-    sysbus_init_child_obj(obj, "cuda", &s->cuda, sizeof(s->cuda), TYPE_CUDA);
+    macio_init_child_obj(s, "cuda", &s->cuda, sizeof(s->cuda), TYPE_CUDA);
 
     object_initialize(&os->nvram, sizeof(os->nvram), TYPE_MACIO_NVRAM);
     dev = DEVICE(&os->nvram);
@@ -340,7 +349,7 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
         object_property_set_link(OBJECT(&s->pmu), OBJECT(sysbus_dev), "gpio",
                                  &error_abort);
         qdev_prop_set_bit(DEVICE(&s->pmu), "has-adb", ns->has_adb);
-        qdev_set_parent_bus(DEVICE(&s->pmu), sysbus_get_default());
+        qdev_set_parent_bus(DEVICE(&s->pmu), BUS(&s->macio_bus));
         object_property_add_child(OBJECT(s), "pmu", OBJECT(&s->pmu), NULL);
 
         object_property_set_bool(OBJECT(&s->pmu), true, "realized", &err);
@@ -356,7 +365,7 @@ static void macio_newworld_realize(PCIDevice *d, Error **errp)
     } else {
         /* CUDA */
         object_initialize(&s->cuda, sizeof(s->cuda), TYPE_CUDA);
-        qdev_set_parent_bus(DEVICE(&s->cuda), sysbus_get_default());
+        qdev_set_parent_bus(DEVICE(&s->cuda), BUS(&s->macio_bus));
         object_property_add_child(OBJECT(s), "cuda", OBJECT(&s->cuda), NULL);
         qdev_prop_set_uint64(DEVICE(&s->cuda), "timebase-frequency",
                              s->frequency);
@@ -385,8 +394,8 @@ static void macio_newworld_init(Object *obj)
                              qdev_prop_allow_set_link_before_realize,
                              0, NULL);
 
-    sysbus_init_child_obj(obj, "gpio", &ns->gpio, sizeof(ns->gpio),
-                          TYPE_MACIO_GPIO);
+    macio_init_child_obj(s, "gpio", &ns->gpio, sizeof(ns->gpio),
+                         TYPE_MACIO_GPIO);
 
     for (i = 0; i < 2; i++) {
         macio_init_ide(s, &ns->ide[i], sizeof(ns->ide[i]), i);
@@ -399,10 +408,13 @@ static void macio_instance_init(Object *obj)
 
     memory_region_init(&s->bar, obj, "macio", 0x80000);
 
-    sysbus_init_child_obj(obj, "dbdma", &s->dbdma, sizeof(s->dbdma),
-                          TYPE_MAC_DBDMA);
+    qbus_create_inplace(&s->macio_bus, sizeof(s->macio_bus), TYPE_MACIO_BUS,
+                        DEVICE(obj), "macio.0");
 
-    sysbus_init_child_obj(obj, "escc", &s->escc, sizeof(s->escc), TYPE_ESCC);
+    macio_init_child_obj(s, "dbdma", &s->dbdma, sizeof(s->dbdma),
+                         TYPE_MAC_DBDMA);
+
+    macio_init_child_obj(s, "escc", &s->escc, sizeof(s->escc), TYPE_ESCC);
 }
 
 static const VMStateDescription vmstate_macio_oldworld = {
@@ -470,6 +482,12 @@ static void macio_class_init(ObjectClass *klass, void *data)
     dc->user_creatable = false;
 }
 
+static const TypeInfo macio_bus_info = {
+    .name = TYPE_MACIO_BUS,
+    .parent = TYPE_BUS,
+    .instance_size = sizeof(MacIOBusState),
+};
+
 static const TypeInfo macio_oldworld_type_info = {
     .name          = TYPE_OLDWORLD_MACIO,
     .parent        = TYPE_MACIO,
@@ -501,6 +519,7 @@ static const TypeInfo macio_type_info = {
 
 static void macio_register_types(void)
 {
+    type_register_static(&macio_bus_info);
     type_register_static(&macio_type_info);
     type_register_static(&macio_oldworld_type_info);
     type_register_static(&macio_newworld_type_info);
diff --git a/include/hw/misc/macio/macio.h b/include/hw/misc/macio/macio.h
index 0c3964ec12..3189973ee6 100644
--- a/include/hw/misc/macio/macio.h
+++ b/include/hw/misc/macio/macio.h
@@ -34,6 +34,15 @@
 #include "hw/ppc/mac_dbdma.h"
 #include "hw/ppc/openpic.h"
 
+/* MacIO virtual bus */
+#define TYPE_MACIO_BUS "macio-bus"
+#define MACIO_BUS(obj) OBJECT_CHECK(MacIOBusState, (obj), TYPE_MACIO_BUS)
+
+typedef struct MacIOBusState {
+    /*< private >*/
+    BusState parent_obj;
+} MacIOBusState;
+
 /* MacIO IDE */
 #define TYPE_MACIO_IDE "macio-ide"
 #define MACIO_IDE(obj) OBJECT_CHECK(MACIOIDEState, (obj), TYPE_MACIO_IDE)
@@ -68,6 +77,7 @@ typedef struct MacIOState {
     PCIDevice parent;
     /*< public >*/
 
+    MacIOBusState macio_bus;
     MemoryRegion bar;
     CUDAState cuda;
     PMUState pmu;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 3/7] macio: add addr property to macio IDE object
  2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 1/7] macio: move MACIOIDEState type declarations to macio.h Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 2/7] macio: add macio bus to help with fw path generation Mark Cave-Ayland
@ 2018-08-29 16:59 ` Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 4/7] grackle: set device fw_name and address for correct fw path generation Mark Cave-Ayland
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2018-08-29 16:59 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, david

This contains the offset of the IDE controller within the macio address space
and is required to allow the address to be included within the fw path.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/ide/macio.c                | 1 +
 hw/misc/macio/macio.c         | 5 +++--
 include/hw/misc/macio/macio.h | 1 +
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/hw/ide/macio.c b/hw/ide/macio.c
index f23961e241..bab8c45a43 100644
--- a/hw/ide/macio.c
+++ b/hw/ide/macio.c
@@ -461,6 +461,7 @@ static void macio_ide_initfn(Object *obj)
 
 static Property macio_ide_properties[] = {
     DEFINE_PROP_UINT32("channel", MACIOIDEState, channel, 0),
+    DEFINE_PROP_UINT32("addr", MACIOIDEState, addr, -1),
     DEFINE_PROP_END_OF_LIST(),
 };
 
diff --git a/hw/misc/macio/macio.c b/hw/misc/macio/macio.c
index 229bfddb90..94da85c8d7 100644
--- a/hw/misc/macio/macio.c
+++ b/hw/misc/macio/macio.c
@@ -219,10 +219,11 @@ static void macio_init_ide(MacIOState *s, MACIOIDEState *ide, size_t ide_size,
                            int index)
 {
     gchar *name = g_strdup_printf("ide[%i]", index);
+    uint32_t addr = 0x1f000 + ((index + 1) * 0x1000);
 
     macio_init_child_obj(s, name, ide, ide_size, TYPE_MACIO_IDE);
-    memory_region_add_subregion(&s->bar, 0x1f000 + ((index + 1) * 0x1000),
-                                &ide->mem);
+    qdev_prop_set_uint32(DEVICE(ide), "addr", addr);
+    memory_region_add_subregion(&s->bar, addr, &ide->mem);
     g_free(name);
 }
 
diff --git a/include/hw/misc/macio/macio.h b/include/hw/misc/macio/macio.h
index 3189973ee6..970058b6ed 100644
--- a/include/hw/misc/macio/macio.h
+++ b/include/hw/misc/macio/macio.h
@@ -51,6 +51,7 @@ typedef struct MACIOIDEState {
     /*< private >*/
     SysBusDevice parent_obj;
     /*< public >*/
+    uint32_t addr;
     uint32_t channel;
     qemu_irq real_ide_irq;
     qemu_irq real_dma_irq;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 4/7] grackle: set device fw_name and address for correct fw path generation
  2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
                   ` (2 preceding siblings ...)
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 3/7] macio: add addr property to macio IDE object Mark Cave-Ayland
@ 2018-08-29 16:59 ` Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 5/7] mac_oldworld: implement custom FWPathProvider Mark Cave-Ayland
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2018-08-29 16:59 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, david

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/pci-host/grackle.c | 17 +++++++++++++++++
 hw/ppc/mac_oldworld.c |  1 +
 2 files changed, 18 insertions(+)

diff --git a/hw/pci-host/grackle.c b/hw/pci-host/grackle.c
index 4810a4de79..5a151e93e9 100644
--- a/hw/pci-host/grackle.c
+++ b/hw/pci-host/grackle.c
@@ -37,6 +37,7 @@
 typedef struct GrackleState {
     PCIHostState parent_obj;
 
+    uint32_t ofw_addr;
     HeathrowState *pic;
     qemu_irq irqs[4];
     MemoryRegion pci_mmio;
@@ -146,12 +147,28 @@ static const TypeInfo grackle_pci_info = {
     },
 };
 
+static char *grackle_ofw_unit_address(const SysBusDevice *dev)
+{
+    GrackleState *s = GRACKLE_PCI_HOST_BRIDGE(dev);
+
+    return g_strdup_printf("%x", s->ofw_addr);
+}
+
+static Property grackle_properties[] = {
+    DEFINE_PROP_UINT32("ofw-addr", GrackleState, ofw_addr, -1),
+    DEFINE_PROP_END_OF_LIST()
+};
+
 static void grackle_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
 
     dc->realize = grackle_realize;
+    dc->props = grackle_properties;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
+    dc->fw_name = "pci";
+    sbc->explicit_ofw_unit_address = grackle_ofw_unit_address;
 }
 
 static const TypeInfo grackle_host_info = {
diff --git a/hw/ppc/mac_oldworld.c b/hw/ppc/mac_oldworld.c
index 80b5525775..c7b73e274f 100644
--- a/hw/ppc/mac_oldworld.c
+++ b/hw/ppc/mac_oldworld.c
@@ -254,6 +254,7 @@ static void ppc_heathrow_init(MachineState *machine)
 
     /* Grackle PCI host bridge */
     dev = qdev_create(NULL, TYPE_GRACKLE_PCI_HOST_BRIDGE);
+    qdev_prop_set_uint32(dev, "ofw-addr", 0x80000000);
     object_property_set_link(OBJECT(dev), OBJECT(pic_dev), "pic",
                              &error_abort);
     qdev_init_nofail(dev);
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 5/7] mac_oldworld: implement custom FWPathProvider
  2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
                   ` (3 preceding siblings ...)
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 4/7] grackle: set device fw_name and address for correct fw path generation Mark Cave-Ayland
@ 2018-08-29 16:59 ` Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 6/7] uninorth: add ofw-addr property to allow correct fw path generation Mark Cave-Ayland
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2018-08-29 16:59 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, david

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 true
since an additional disk node should not be added except for virtio devices.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 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);
 }
 
+/*
+ * 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 = 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 = MACIO_IDE(dev);
+        return g_strdup_printf("ata-3@%x", macio_ide->addr);
+    }
+
+    if (!strcmp(object_get_typename(OBJECT(dev)), "ide-drive")) {
+        ide_bus = IDE_BUS(qdev_get_parent_bus(dev));
+        ide_s = idebus_active_if(ide_bus);
+
+        if (ide_s->drive_kind == 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 = MACHINE_CLASS(oc);
+    FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc);
 
     mc->desc = "Heathrow based PowerMAC";
     mc->init = ppc_heathrow_init;
@@ -395,12 +445,18 @@ static void heathrow_class_init(ObjectClass *oc, void *data)
     mc->kvm_type = heathrow_kvm_type;
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("750_v3.1");
     mc->default_display = "std";
+    mc->ignore_boot_device_suffixes = true;
+    fwc->get_dev_path = heathrow_fw_dev_path;
 }
 
 static const TypeInfo ppc_heathrow_machine_info = {
     .name          = MACHINE_TYPE_NAME("g3beige"),
     .parent        = TYPE_MACHINE,
-    .class_init    = heathrow_class_init
+    .class_init    = heathrow_class_init,
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_FW_PATH_PROVIDER },
+        { }
+    },
 };
 
 static void ppc_heathrow_register_types(void)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 6/7] uninorth: add ofw-addr property to allow correct fw path generation
  2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
                   ` (4 preceding siblings ...)
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 5/7] mac_oldworld: implement custom FWPathProvider Mark Cave-Ayland
@ 2018-08-29 16:59 ` Mark Cave-Ayland
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 7/7] mac_newworld: implement custom FWPathProvider Mark Cave-Ayland
  2018-08-30  0:46 ` [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices David Gibson
  7 siblings, 0 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2018-08-29 16:59 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, david

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 hw/pci-host/uninorth.c         | 16 ++++++++++++++++
 hw/ppc/mac_newworld.c          |  1 +
 include/hw/pci-host/uninorth.h |  1 +
 3 files changed, 18 insertions(+)

diff --git a/hw/pci-host/uninorth.c b/hw/pci-host/uninorth.c
index a843aa7b36..1378c5c7fb 100644
--- a/hw/pci-host/uninorth.c
+++ b/hw/pci-host/uninorth.c
@@ -118,6 +118,13 @@ static void pci_unin_init_irqs(UNINHostState *s)
     }
 }
 
+static char *pci_unin_main_ofw_unit_address(const SysBusDevice *dev)
+{
+    UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev);
+
+    return g_strdup_printf("%x", s->ofw_addr);
+}
+
 static void pci_unin_main_realize(DeviceState *dev, Error **errp)
 {
     UNINHostState *s = UNI_NORTH_PCI_HOST_BRIDGE(dev);
@@ -455,12 +462,21 @@ static const TypeInfo unin_internal_pci_host_info = {
     },
 };
 
+static Property pci_unin_main_pci_host_props[] = {
+    DEFINE_PROP_UINT32("ofw-addr", UNINHostState, ofw_addr, -1),
+    DEFINE_PROP_END_OF_LIST()
+};
+
 static void pci_unin_main_class_init(ObjectClass *klass, void *data)
 {
     DeviceClass *dc = DEVICE_CLASS(klass);
+    SysBusDeviceClass *sbc = SYS_BUS_DEVICE_CLASS(klass);
 
     dc->realize = pci_unin_main_realize;
+    dc->props = pci_unin_main_pci_host_props;
     set_bit(DEVICE_CATEGORY_BRIDGE, dc->categories);
+    dc->fw_name = "pci";
+    sbc->explicit_ofw_unit_address = pci_unin_main_ofw_unit_address;
 }
 
 static const TypeInfo pci_unin_main_info = {
diff --git a/hw/ppc/mac_newworld.c b/hw/ppc/mac_newworld.c
index a6b95f024c..325013f563 100644
--- a/hw/ppc/mac_newworld.c
+++ b/hw/ppc/mac_newworld.c
@@ -344,6 +344,7 @@ static void ppc_core99_init(MachineState *machine)
 
         /* Uninorth main bus */
         dev = qdev_create(NULL, TYPE_UNI_NORTH_PCI_HOST_BRIDGE);
+        qdev_prop_set_uint32(dev, "ofw-addr", 0xf2000000);
         object_property_set_link(OBJECT(dev), OBJECT(pic_dev), "pic",
                                  &error_abort);
         qdev_init_nofail(dev);
diff --git a/include/hw/pci-host/uninorth.h b/include/hw/pci-host/uninorth.h
index 2a1cf9f284..060324536a 100644
--- a/include/hw/pci-host/uninorth.h
+++ b/include/hw/pci-host/uninorth.h
@@ -49,6 +49,7 @@
 typedef struct UNINHostState {
     PCIHostState parent_obj;
 
+    uint32_t ofw_addr;
     OpenPICState *pic;
     qemu_irq irqs[4];
     MemoryRegion pci_mmio;
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [Qemu-devel] [PATCH 7/7] mac_newworld: implement custom FWPathProvider
  2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
                   ` (5 preceding siblings ...)
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 6/7] uninorth: add ofw-addr property to allow correct fw path generation Mark Cave-Ayland
@ 2018-08-29 16:59 ` Mark Cave-Ayland
  2018-08-30  0:46 ` [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices David Gibson
  7 siblings, 0 replies; 9+ messages in thread
From: Mark Cave-Ayland @ 2018-08-29 16:59 UTC (permalink / raw)
  To: qemu-devel, qemu-ppc, david

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 true
since an additional disk node should not be added except for virtio devices.

Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>
---
 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);
 }
 
+/*
+ * 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 = 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 = MACIO_IDE(dev);
+        return g_strdup_printf("ata-3@%x", macio_ide->addr);
+    }
+
+    if (!strcmp(object_get_typename(OBJECT(dev)), "ide-drive")) {
+        ide_bus = IDE_BUS(qdev_get_parent_bus(dev));
+        ide_s = idebus_active_if(ide_bus);
+
+        if (ide_s->drive_kind == 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 = MACHINE_CLASS(oc);
+    FWPathProviderClass *fwc = FW_PATH_PROVIDER_CLASS(oc);
 
     mc->desc = "Mac99 based PowerMAC";
     mc->init = ppc_core99_init;
@@ -543,6 +593,8 @@ static void core99_machine_class_init(ObjectClass *oc, void *data)
 #else
     mc->default_cpu_type = POWERPC_CPU_TYPE_NAME("7400_v2.9");
 #endif
+    mc->ignore_boot_device_suffixes = true;
+    fwc->get_dev_path = core99_fw_dev_path;
 }
 
 static char *core99_get_via_config(Object *obj, Error **errp)
@@ -599,7 +651,11 @@ static const TypeInfo core99_machine_info = {
     .parent        = TYPE_MACHINE,
     .class_init    = core99_machine_class_init,
     .instance_init = core99_instance_init,
-    .instance_size = sizeof(Core99MachineState)
+    .instance_size = sizeof(Core99MachineState),
+    .interfaces = (InterfaceInfo[]) {
+        { TYPE_FW_PATH_PROVIDER },
+        { }
+    },
 };
 
 static void mac_machine_register_types(void)
-- 
2.11.0

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* Re: [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices
  2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
                   ` (6 preceding siblings ...)
  2018-08-29 16:59 ` [Qemu-devel] [PATCH 7/7] mac_newworld: implement custom FWPathProvider Mark Cave-Ayland
@ 2018-08-30  0:46 ` David Gibson
  7 siblings, 0 replies; 9+ messages in thread
From: David Gibson @ 2018-08-30  0:46 UTC (permalink / raw)
  To: Mark Cave-Ayland; +Cc: qemu-devel, qemu-ppc

[-- Attachment #1: Type: text/plain, Size: 1952 bytes --]

On Wed, Aug 29, 2018 at 05:59:04PM +0100, Mark Cave-Ayland wrote:
1;5202;0c> This patchset is the QEMU counterpart to the patches posted on the OpenBIOS
> list at https://mail.coreboot.org/pipermail/openbios/2018-August/010422.html
> which generate correct fw paths for the Mac Old World and New World machines.
> 
> With these patches applied QEMU generates the correct fw paths for both the
> in-built macio IDE and virtio-blk-pci devices enabling support for bootindex
> and most importantly with an updated OpenBIOS, allowing boot from
> virtio-pci-blk devices.
> 
> Signed-off-by: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>

Applied to ppc-for-3.1, thanks.


> 
> 
> Mark Cave-Ayland (7):
>   macio: move MACIOIDEState type declarations to macio.h
>   macio: add macio bus to help with fw path generation
>   macio: add addr property to macio IDE object
>   grackle: set device fw_name and address for correct fw path generation
>   mac_oldworld: implement custom FWPathProvider
>   uninorth: add ofw-addr property to allow correct fw path generation
>   mac_newworld: implement custom FWPathProvider
> 
>  hw/ide/macio.c                 |  2 ++
>  hw/misc/macio/macio.c          | 42 ++++++++++++++++++++++--------
>  hw/pci-host/grackle.c          | 17 ++++++++++++
>  hw/pci-host/uninorth.c         | 16 ++++++++++++
>  hw/ppc/mac.h                   | 26 -------------------
>  hw/ppc/mac_newworld.c          | 59 +++++++++++++++++++++++++++++++++++++++++-
>  hw/ppc/mac_oldworld.c          | 59 +++++++++++++++++++++++++++++++++++++++++-
>  include/hw/misc/macio/macio.h  | 37 ++++++++++++++++++++++++++
>  include/hw/pci-host/uninorth.h |  1 +
>  9 files changed, 220 insertions(+), 39 deletions(-)
> 

-- 
David Gibson			| I'll have my music baroque, and my code
david AT gibson.dropbear.id.au	| minimalist, thank you.  NOT _the_ _other_
				| _way_ _around_!
http://www.ozlabs.org/~dgibson

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2018-08-30  1:19 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-08-29 16:59 [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices Mark Cave-Ayland
2018-08-29 16:59 ` [Qemu-devel] [PATCH 1/7] macio: move MACIOIDEState type declarations to macio.h Mark Cave-Ayland
2018-08-29 16:59 ` [Qemu-devel] [PATCH 2/7] macio: add macio bus to help with fw path generation Mark Cave-Ayland
2018-08-29 16:59 ` [Qemu-devel] [PATCH 3/7] macio: add addr property to macio IDE object Mark Cave-Ayland
2018-08-29 16:59 ` [Qemu-devel] [PATCH 4/7] grackle: set device fw_name and address for correct fw path generation Mark Cave-Ayland
2018-08-29 16:59 ` [Qemu-devel] [PATCH 5/7] mac_oldworld: implement custom FWPathProvider Mark Cave-Ayland
2018-08-29 16:59 ` [Qemu-devel] [PATCH 6/7] uninorth: add ofw-addr property to allow correct fw path generation Mark Cave-Ayland
2018-08-29 16:59 ` [Qemu-devel] [PATCH 7/7] mac_newworld: implement custom FWPathProvider Mark Cave-Ayland
2018-08-30  0:46 ` [Qemu-devel] [PATCH 0/7] mac: generate correct fw paths for macio IDE and virtio-blk-pci devices David Gibson

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.