[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 06/28] serial: make SerialMMState actually a different type
From: |
Marc-André Lureau |
Subject: |
[PATCH v2 06/28] serial: make SerialMMState actually a different type |
Date: |
Tue, 22 Oct 2019 18:21:15 +0200 |
And move the "it_shift" field there, since it's specific.
Signed-off-by: Marc-André Lureau <address@hidden>
---
hw/char/serial.c | 10 ++++++----
include/hw/char/serial.h | 9 +++++++--
2 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/hw/char/serial.c b/hw/char/serial.c
index b623c4e79f..4fc2bcedf1 100644
--- a/hw/char/serial.c
+++ b/hw/char/serial.c
@@ -1025,14 +1025,14 @@ static const TypeInfo serial_info = {
static uint64_t serial_mm_read(void *opaque, hwaddr addr,
unsigned size)
{
- SerialState *s = opaque;
+ SerialMMState *s = SERIAL_MM(opaque);
return serial_ioport_read(s, addr >> s->it_shift, 1);
}
static void serial_mm_write(void *opaque, hwaddr addr,
uint64_t value, unsigned size)
{
- SerialState *s = opaque;
+ SerialMMState *s = SERIAL_MM(opaque);
value &= 255;
serial_ioport_write(s, addr >> s->it_shift, value, 1);
}
@@ -1066,10 +1066,11 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
qemu_irq irq, int baudbase,
Chardev *chr, enum device_endian end)
{
- DeviceState *dev = DEVICE(object_new(TYPE_SERIAL));
+ DeviceState *dev = DEVICE(object_new(TYPE_SERIAL_MM));
+ SerialMMState *m = SERIAL_MM(dev);
SerialState *s = SERIAL(dev);
- s->it_shift = it_shift;
+ m->it_shift = it_shift;
s->irq = irq;
s->baudbase = baudbase;
qdev_prop_set_chr(dev, "chardev", chr);
@@ -1088,6 +1089,7 @@ SerialState *serial_mm_init(MemoryRegion *address_space,
static const TypeInfo serial_mm_info = {
.name = TYPE_SERIAL_MM,
.parent = TYPE_SERIAL,
+ .instance_size = sizeof(SerialMMState),
};
static void serial_register_types(void)
diff --git a/include/hw/char/serial.h b/include/hw/char/serial.h
index 2b8dbd88f1..62962e3c5a 100644
--- a/include/hw/char/serial.h
+++ b/include/hw/char/serial.h
@@ -57,7 +57,6 @@ typedef struct SerialState {
qemu_irq irq;
CharBackend chr;
int last_break_enable;
- int it_shift;
int baudbase;
uint32_t tsr_retry;
guint watch_tag;
@@ -80,6 +79,12 @@ typedef struct SerialState {
MemoryRegion io;
} SerialState;
+typedef struct SerialMMState {
+ SerialState parent;
+
+ int it_shift;
+} SerialMMState;
+
extern const VMStateDescription vmstate_serial;
extern const MemoryRegionOps serial_io_ops;
@@ -91,7 +96,7 @@ void serial_set_frequency(SerialState *s, uint32_t frequency);
#define SERIAL(s) OBJECT_CHECK(SerialState, (s), TYPE_SERIAL)
#define TYPE_SERIAL_MM "serial-mm"
-#define SERIAL_MM(s) OBJECT_CHECK(SerialState, (s), TYPE_SERIAL_MM)
+#define SERIAL_MM(s) OBJECT_CHECK(SerialMMState, (s), TYPE_SERIAL_MM)
SerialState *serial_init(int base, qemu_irq irq, int baudbase,
Chardev *chr, MemoryRegion *system_io);
--
2.23.0.606.g08da6496b6
- [PATCH v2 00/28] Clean-ups: qom-ify serial and remove QDEV_PROP_PTR, Marc-André Lureau, 2019/10/22
- [PATCH v2 01/28] chardev: generate an internal id when none given, Marc-André Lureau, 2019/10/22
- [PATCH v2 02/28] serial-pci-multi: factor out multi_serial_get_nr_ports, Marc-André Lureau, 2019/10/22
- [PATCH v2 03/28] serial: initial qom-ification, Marc-André Lureau, 2019/10/22
- [PATCH v2 04/28] serial: register vmsd with DeviceClass, Marc-André Lureau, 2019/10/22
- [PATCH v2 05/28] serial: add and set "chardev" property, Marc-André Lureau, 2019/10/22
- [PATCH v2 06/28] serial: make SerialMMState actually a different type,
Marc-André Lureau <=
- [PATCH v2 07/28] serial: add and set "regshift" property, Marc-André Lureau, 2019/10/22
- [PATCH v2 08/28] serial: convert irq to qdev gpio properties, Marc-André Lureau, 2019/10/22
- [PATCH v2 10/28] serial: add "base" property, Marc-André Lureau, 2019/10/22
- [PATCH v2 09/28] serial: add "baudbase" property, Marc-André Lureau, 2019/10/22
- [PATCH v2 11/28] serial: realize the serial device, Marc-André Lureau, 2019/10/22
- [PATCH v2 12/28] serial: replace serial_exit_core() with unrealize, Marc-André Lureau, 2019/10/22
- [PATCH v2 13/28] serial: factor out serial_mm_connect, Marc-André Lureau, 2019/10/22