diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2018-03-08 23:39:33 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-03-12 16:12:48 +0100 |
commit | 6f6695b13638b0a4bfd9f75c022a9a7c55fb0b51 (patch) | |
tree | 1ca0ff586c3d6a9cdced11d7775838ba46a43b19 /hw/isa/isa-superio.c | |
parent | cd9526ab7c04f2c32c63340b04401f6ed25682b9 (diff) |
hw/isa/superio: Factor out the floppy disc controller code from pc87312.c
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180308223946.26784-13-f4bug@amsat.org>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Diffstat (limited to 'hw/isa/isa-superio.c')
-rw-r--r-- | hw/isa/isa-superio.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index 6962421aad..4b5e280b38 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -11,7 +11,10 @@ */ #include "qemu/osdep.h" #include "qemu/error-report.h" +#include "qapi/error.h" #include "sysemu/sysemu.h" +#include "sysemu/block-backend.h" +#include "sysemu/blockdev.h" #include "chardev/char.h" #include "hw/isa/superio.h" #include "hw/char/serial.h" @@ -25,6 +28,7 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) ISADevice *isa; DeviceState *d; Chardev *chr; + DriveInfo *drive; char *name; int i; @@ -107,6 +111,38 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) g_free(name); } } + + /* Floppy disc */ + if (!k->floppy.is_enabled || k->floppy.is_enabled(sio, 0)) { + isa = isa_create(bus, "isa-fdc"); + d = DEVICE(isa); + if (k->floppy.get_iobase) { + qdev_prop_set_uint32(d, "iobase", k->floppy.get_iobase(sio, 0)); + } + if (k->floppy.get_irq) { + qdev_prop_set_uint32(d, "irq", k->floppy.get_irq(sio, 0)); + } + /* FIXME use a qdev drive property instead of drive_get() */ + drive = drive_get(IF_FLOPPY, 0, 0); + if (drive != NULL) { + qdev_prop_set_drive(d, "driveA", blk_by_legacy_dinfo(drive), + &error_fatal); + } + /* FIXME use a qdev drive property instead of drive_get() */ + drive = drive_get(IF_FLOPPY, 0, 1); + if (drive != NULL) { + qdev_prop_set_drive(d, "driveB", blk_by_legacy_dinfo(drive), + &error_fatal); + } + qdev_init_nofail(d); + sio->floppy = isa; + trace_superio_create_floppy(0, + k->floppy.get_iobase ? + k->floppy.get_iobase(sio, 0) : -1, + k->floppy.get_irq ? + k->floppy.get_irq(sio, 0) : -1); + } + } static void isa_superio_class_init(ObjectClass *oc, void *data) |