diff options
author | Philippe Mathieu-Daudé <f4bug@amsat.org> | 2018-03-08 23:39:32 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2018-03-12 16:12:48 +0100 |
commit | cd9526ab7c04f2c32c63340b04401f6ed25682b9 (patch) | |
tree | c2ccc4678aadf3ef0ea576fa56b1abc8eeb24a50 /hw/isa/isa-superio.c | |
parent | 4c3119a6e3ea7bdab718015b6f5176cfaf52f7ce (diff) | |
download | qemu-cd9526ab7c04f2c32c63340b04401f6ed25682b9.zip qemu-cd9526ab7c04f2c32c63340b04401f6ed25682b9.tar.gz qemu-cd9526ab7c04f2c32c63340b04401f6ed25682b9.tar.bz2 |
hw/isa/superio: Factor out the serial code from pc87312.c
Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org>
Message-Id: <20180308223946.26784-12-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 | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/hw/isa/isa-superio.c b/hw/isa/isa-superio.c index eb263fc..6962421 100644 --- a/hw/isa/isa-superio.c +++ b/hw/isa/isa-superio.c @@ -14,6 +14,7 @@ #include "sysemu/sysemu.h" #include "chardev/char.h" #include "hw/isa/superio.h" +#include "hw/char/serial.h" #include "trace.h" static void isa_superio_realize(DeviceState *dev, Error **errp) @@ -66,6 +67,46 @@ static void isa_superio_realize(DeviceState *dev, Error **errp) g_free(name); } } + + /* Serial */ + for (i = 0; i < k->serial.count; i++) { + if (i >= ARRAY_SIZE(sio->serial)) { + warn_report("superio: ignoring %td serial controllers", + k->serial.count - ARRAY_SIZE(sio->serial)); + break; + } + if (!k->serial.is_enabled || k->serial.is_enabled(sio, i)) { + /* FIXME use a qdev chardev prop instead of serial_hds[] */ + chr = serial_hds[i]; + if (chr == NULL || chr->be) { + name = g_strdup_printf("discarding-serial%d", i); + chr = qemu_chr_new(name, "null"); + } else { + name = g_strdup_printf("serial%d", i); + } + isa = isa_create(bus, TYPE_ISA_SERIAL); + d = DEVICE(isa); + qdev_prop_set_uint32(d, "index", i); + if (k->serial.get_iobase) { + qdev_prop_set_uint32(d, "iobase", + k->serial.get_iobase(sio, i)); + } + if (k->serial.get_irq) { + qdev_prop_set_uint32(d, "irq", k->serial.get_irq(sio, i)); + } + qdev_prop_set_chr(d, "chardev", chr); + qdev_init_nofail(d); + sio->serial[i] = isa; + trace_superio_create_serial(i, + k->serial.get_iobase ? + k->serial.get_iobase(sio, i) : -1, + k->serial.get_irq ? + k->serial.get_irq(sio, i) : -1); + object_property_add_child(OBJECT(dev), name, + OBJECT(sio->serial[0]), NULL); + g_free(name); + } + } } static void isa_superio_class_init(ObjectClass *oc, void *data) |