qemu-ppc
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-ppc] [PATCH RFC for-2.3? 6/8] pc87312: Create FDC in-place


From: Andreas Färber
Subject: [Qemu-ppc] [PATCH RFC for-2.3? 6/8] pc87312: Create FDC in-place
Date: Sun, 29 Mar 2015 19:53:21 +0200

Move drive_get() code to PReP machine.

Signed-off-by: Andreas Färber <address@hidden>
---
 hw/isa/pc87312.c         | 32 ++++++++++++++++----------------
 hw/ppc/prep.c            | 11 +++++++++++
 include/hw/isa/pc87312.h |  6 ++----
 3 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/hw/isa/pc87312.c b/hw/isa/pc87312.c
index 207eaa8..d35eb0e 100644
--- a/hw/isa/pc87312.c
+++ b/hw/isa/pc87312.c
@@ -266,7 +266,6 @@ static void pc87312_realize(DeviceState *dev, Error **errp)
     DeviceState *d;
     ISADevice *isa;
     ISABus *bus;
-    DriveInfo *drive;
     Error *local_err = NULL;
     int i;
 
@@ -311,23 +310,17 @@ static void pc87312_realize(DeviceState *dev, Error 
**errp)
     }
 
     if (is_fdc_enabled(s)) {
-        isa = isa_create(bus, "isa-fdc");
-        d = DEVICE(isa);
+        d = DEVICE(&s->fdc);
+        qdev_set_parent_bus(d, BUS(bus));
         qdev_prop_set_uint32(d, "iobase", get_fdc_iobase(s));
-        qdev_prop_set_uint32(d, "irq", 6);
-        drive = drive_get(IF_FLOPPY, 0, 0);
-        if (drive != NULL) {
-            qdev_prop_set_drive_nofail(d, "driveA",
-                                       blk_by_legacy_dinfo(drive));
-        }
-        drive = drive_get(IF_FLOPPY, 0, 1);
-        if (drive != NULL) {
-            qdev_prop_set_drive_nofail(d, "driveB",
-                                       blk_by_legacy_dinfo(drive));
-        }
-        qdev_init_nofail(d);
-        s->fdc.dev = isa;
         trace_pc87312_info_floppy(get_fdc_iobase(s));
+        object_property_set_bool(OBJECT(&s->fdc), true, "realized",
+                                 &local_err);
+        object_unref(OBJECT(&s->fdc));
+        if (local_err) {
+            error_propagate(errp, local_err);
+            return;
+        }
     }
 
     if (is_ide_enabled(s)) {
@@ -363,6 +356,13 @@ static void pc87312_initfn(Object *obj)
                                   &error_abort);
         g_free(propname);
     }
+
+    object_initialize(&s->fdc, sizeof(s->fdc), TYPE_ISA_FDC);
+    object_property_add_alias(obj, "fdc-driveA",
+                              OBJECT(&s->fdc), "driveA", &error_abort);
+    object_property_add_alias(obj, "fdc-driveB",
+                              OBJECT(&s->fdc), "driveB", &error_abort);
+    qdev_prop_set_uint32(DEVICE(&s->fdc), "irq", 6);
 }
 
 static const VMStateDescription vmstate_pc87312 = {
diff --git a/hw/ppc/prep.c b/hw/ppc/prep.c
index eb29d3c..272a284 100644
--- a/hw/ppc/prep.c
+++ b/hw/ppc/prep.c
@@ -530,6 +530,7 @@ static void ppc_prep_init(MachineState *machine)
     ISABus *isa_bus;
     ISADevice *isa;
     CharDriverState *chr;
+    DriveInfo *drive;
     qemu_irq *cpu_exit_irq;
     int ppc_boot_device;
     DriveInfo *hd[MAX_IDE_BUS * MAX_IDE_DEVS];
@@ -661,6 +662,16 @@ static void ppc_prep_init(MachineState *machine)
             g_free(name);
         }
     }
+    drive = drive_get(IF_FLOPPY, 0, 0);
+    if (drive != NULL) {
+        qdev_prop_set_drive_nofail(dev, "fdc-driveA",
+                                   blk_by_legacy_dinfo(drive));
+    }
+    drive = drive_get(IF_FLOPPY, 0, 1);
+    if (drive != NULL) {
+        qdev_prop_set_drive_nofail(dev, "fdc-driveB",
+                                   blk_by_legacy_dinfo(drive));
+    }
     qdev_prop_set_uint8(dev, "config", 13); /* fdc, ser0, ser1, par0 */
     qdev_init_nofail(dev);
 
diff --git a/include/hw/isa/pc87312.h b/include/hw/isa/pc87312.h
index 3256e0f..c49a06d 100644
--- a/include/hw/isa/pc87312.h
+++ b/include/hw/isa/pc87312.h
@@ -28,6 +28,7 @@
 #include "hw/isa/isa.h"
 #include "hw/char/parallel.h"
 #include "hw/char/serial.h"
+#include "hw/block/fdc.h"
 
 
 #define TYPE_PC87312 "pc87312"
@@ -41,10 +42,7 @@ typedef struct PC87312State {
 
     ISAParallelState parallel;
     ISASerialState uart[2];
-
-    struct {
-        ISADevice *dev;
-    } fdc;
+    FDCtrlISABus fdc;
 
     struct {
         ISADevice *dev;
-- 
2.1.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]