summaryrefslogtreecommitdiffstats
path: root/include/hw
diff options
context:
space:
mode:
authorMarc-André Lureau2019-10-21 23:32:12 +0200
committerMarc-André Lureau2020-01-07 13:50:15 +0100
commit7781b88ee458ff933459503ade0b0a6ddaad08de (patch)
tree9bbe400fc3c5d02e5b36ebb89ce4db84f2bef2f3 /include/hw
parentserial-pci-multi: factor out multi_serial_get_port_count() (diff)
downloadqemu-7781b88ee458ff933459503ade0b0a6ddaad08de.tar.gz
qemu-7781b88ee458ff933459503ade0b0a6ddaad08de.tar.xz
qemu-7781b88ee458ff933459503ade0b0a6ddaad08de.zip
serial: initial qom-ification
Make SerialState a device (the following patches will introduce IO/MM sysbus serial devices) None of the serial_{,mm}_init() callers actually free the returned value (even if they did, it would be quite harmless), so we can change the object allocation at will. However, the devices that embed SerialState must now have their field QOM-initialized manually (isa, pci, pci-multi). Signed-off-by: Marc-André Lureau <marcandre.lureau@redhat.com> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include/hw')
-rw-r--r--include/hw/char/serial.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 8be3d8a4f9..180cc7c24e 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -30,10 +30,13 @@
#include "exec/memory.h"
#include "qemu/fifo8.h"
#include "chardev/char.h"
+#include "hw/sysbus.h"
#define UART_FIFO_LENGTH 16 /* 16550A Fifo Length */
typedef struct SerialState {
+ DeviceState parent;
+
uint16_t divider;
uint8_t rbr; /* receive register */
uint8_t thr; /* transmit holding register */
@@ -84,7 +87,9 @@ void serial_realize_core(SerialState *s, Error **errp);
void serial_exit_core(SerialState *s);
void serial_set_frequency(SerialState *s, uint32_t frequency);
-/* legacy pre qom */
+#define TYPE_SERIAL "serial"
+#define SERIAL(s) OBJECT_CHECK(SerialState, (s), TYPE_SERIAL)
+
SerialState *serial_init(int base, qemu_irq irq, int baudbase,
Chardev *chr, MemoryRegion *system_io);
SerialState *serial_mm_init(MemoryRegion *address_space,