summaryrefslogtreecommitdiffstats
path: root/include/hw/char
diff options
context:
space:
mode:
authorPeter Maydell2020-01-07 18:54:29 +0100
committerPeter Maydell2020-01-07 18:54:29 +0100
commit1bbd1511b617eaffc1da22cde33bc01c12fb450f (patch)
tree846f72c19b03ffdec2a8b49f6fc91e070fcc3dd6 /include/hw/char
parentMerge remote-tracking branch 'remotes/vivier/tags/q800-for-5.0-pull-request' ... (diff)
parentqdev/qom: remove some TODO limitations now that PROP_PTR is gone (diff)
downloadqemu-1bbd1511b617eaffc1da22cde33bc01c12fb450f.tar.gz
qemu-1bbd1511b617eaffc1da22cde33bc01c12fb450f.tar.xz
qemu-1bbd1511b617eaffc1da22cde33bc01c12fb450f.zip
Merge remote-tracking branch 'remotes/elmarco/tags/prop-ptr-pull-request' into staging
Clean-ups: qom-ify serial and remove QDEV_PROP_PTR Hi, QDEV_PROP_PTR is marked in multiple places as "FIXME/TODO/remove me". In most cases, it can be easily replaced with QDEV_PROP_LINK when the pointer points to an Object. There are a few places where such substitution isn't possible. For those places, it seems reasonable to use a specific setter method instead, and keep the user_creatable = false. In other places, proper usage of qdev or other facilies is the solution. The serial code wasn't converted to qdev, which makes it a bit more archaic to deal with. Let's convert it first, so we can more easily embed it from other devices, and re-export some properties and drop QDEV_PROP_PTR usage. # gpg: Signature made Tue 07 Jan 2020 15:01:26 GMT # gpg: using RSA key 87A9BD933F87C606D276F62DDAE8E10975969CE5 # gpg: issuer "marcandre.lureau@redhat.com" # gpg: Good signature from "Marc-André Lureau <marcandre.lureau@redhat.com>" [full] # gpg: aka "Marc-André Lureau <marcandre.lureau@gmail.com>" [full] # Primary key fingerprint: 87A9 BD93 3F87 C606 D276 F62D DAE8 E109 7596 9CE5 * remotes/elmarco/tags/prop-ptr-pull-request: (37 commits) qdev/qom: remove some TODO limitations now that PROP_PTR is gone qdev: remove QDEV_PROP_PTR qdev: remove PROP_MEMORY_REGION omap-gpio: remove PROP_PTR omap-i2c: remove PROP_PTR omap-intc: remove PROP_PTR smbus-eeprom: remove PROP_PTR cris: improve passing PIC interrupt vector to the CPU mips/cps: fix setting saar property qdev: use g_strcmp0() instead of open-coding it leon3: use qdev gpio facilities for the PIL leon3: use qemu_irq framework instead of callback as property dp8393x: replace PROP_PTR with PROP_LINK etraxfs: remove PROP_PTR usage lance: replace PROP_PTR with PROP_LINK vmmouse: replace PROP_PTR with PROP_LINK sm501: make SerialMM a child, export chardev property mips: use sysbus_mmio_get_region() instead of internal fields mips: use sysbus_add_io() mips: baudbase is 115200 by default ... Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'include/hw/char')
-rw-r--r--include/hw/char/serial.h43
1 files changed, 32 insertions, 11 deletions
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 8be3d8a4f9..535fa23a2b 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 */
@@ -54,8 +57,7 @@ typedef struct SerialState {
qemu_irq irq;
CharBackend chr;
int last_break_enable;
- int it_shift;
- int baudbase;
+ uint32_t baudbase;
uint32_t tsr_retry;
guint watch_tag;
uint32_t wakeup;
@@ -77,20 +79,39 @@ typedef struct SerialState {
MemoryRegion io;
} SerialState;
+typedef struct SerialMM {
+ SysBusDevice parent;
+
+ SerialState serial;
+
+ uint8_t regshift;
+ uint8_t endianness;
+} SerialMM;
+
+typedef struct SerialIO {
+ SysBusDevice parent;
+
+ SerialState serial;
+} SerialIO;
+
extern const VMStateDescription vmstate_serial;
extern const MemoryRegionOps serial_io_ops;
-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 */
-SerialState *serial_init(int base, qemu_irq irq, int baudbase,
- Chardev *chr, MemoryRegion *system_io);
-SerialState *serial_mm_init(MemoryRegion *address_space,
- hwaddr base, int it_shift,
- qemu_irq irq, int baudbase,
- Chardev *chr, enum device_endian end);
+#define TYPE_SERIAL "serial"
+#define SERIAL(s) OBJECT_CHECK(SerialState, (s), TYPE_SERIAL)
+
+#define TYPE_SERIAL_MM "serial-mm"
+#define SERIAL_MM(s) OBJECT_CHECK(SerialMM, (s), TYPE_SERIAL_MM)
+
+#define TYPE_SERIAL_IO "serial-io"
+#define SERIAL_IO(s) OBJECT_CHECK(SerialIO, (s), TYPE_SERIAL_IO)
+
+SerialMM *serial_mm_init(MemoryRegion *address_space,
+ hwaddr base, int regshift,
+ qemu_irq irq, int baudbase,
+ Chardev *chr, enum device_endian end);
/* serial-isa.c */