[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC 5/9] hw/virtio-serial-bus.c: Add virtio-serial device.
From: |
Evgeny Voevodin |
Subject: |
[Qemu-devel] [RFC 5/9] hw/virtio-serial-bus.c: Add virtio-serial device. |
Date: |
Wed, 25 Apr 2012 09:54:13 +0400 |
Signed-off-by: Evgeny Voevodin <address@hidden>
---
hw/virtio-serial-bus.c | 42 ++++++++++++++++++++++++++++++++++++++++++
hw/virtio-serial.h | 9 +++++++++
2 files changed, 51 insertions(+), 0 deletions(-)
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index e22940e..52a5382 100644
--- a/hw/virtio-serial-bus.c
+++ b/hw/virtio-serial-bus.c
@@ -24,6 +24,7 @@
#include "sysbus.h"
#include "trace.h"
#include "virtio-serial.h"
+#include "virtio-transport.h"
/* The virtio-serial bus on top of which the ports will ride as devices */
struct VirtIOSerialBus {
@@ -955,3 +956,44 @@ static void virtio_serial_register_types(void)
}
type_init(virtio_serial_register_types)
+
+/******************** VirtIOSer Device **********************/
+
+static int virtio_serialdev_init(DeviceState *dev)
+{
+ VirtIODevice *vdev;
+ VirtIOSerState *proxy = VIRTIO_SERIAL_FROM_QDEV(dev);
+ vdev = virtio_serial_init(dev, &proxy->serial);
+ if (!vdev) {
+ return -1;
+ }
+ return virtio_init_transport(dev, vdev);
+}
+
+static Property virtio_serial_properties[] = {
+ DEFINE_PROP_UINT32("max_ports", VirtIOSerState,
+ serial.max_virtserial_ports, 31),
+ DEFINE_PROP_END_OF_LIST(),
+};
+
+static void virtio_serial_class_init(ObjectClass *klass, void *data)
+{
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ dc->init = virtio_serialdev_init;
+ dc->props = virtio_serial_properties;
+ dc->bus_info = &virtio_transport_bus_info;
+}
+
+static TypeInfo virtio_serial_info = {
+ .name = "virtio-serial",
+ .parent = TYPE_DEVICE,
+ .instance_size = sizeof(VirtIOSerState),
+ .class_init = virtio_serial_class_init,
+};
+
+static void virtio_ser_register_types(void)
+{
+ type_register_static(&virtio_serial_info);
+}
+
+type_init(virtio_ser_register_types)
diff --git a/hw/virtio-serial.h b/hw/virtio-serial.h
index 16e3982..2290aac 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -15,6 +15,7 @@
#ifndef _QEMU_VIRTIO_SERIAL_H
#define _QEMU_VIRTIO_SERIAL_H
+#include "sysbus.h"
#include "qdev.h"
#include "virtio.h"
@@ -173,6 +174,14 @@ struct VirtIOSerialPort {
bool throttled;
};
+typedef struct {
+ DeviceState qdev;
+ /* virtio-serial */
+ virtio_serial_conf serial;
+} VirtIOSerState;
+
+#define VIRTIO_SERIAL_FROM_QDEV(dev) DO_UPCAST(VirtIOSerState, qdev, dev)
+
/* Interface to the virtio-serial bus */
/*
--
1.7.5.4
- [Qemu-devel] [RFC 0/9] Virtio-mmio refactoring., Evgeny Voevodin, 2012/04/25
- [Qemu-devel] [RFC 1/9] virtio: Add support for guest setting of queue size, Evgeny Voevodin, 2012/04/25
- [Qemu-devel] [RFC 5/9] hw/virtio-serial-bus.c: Add virtio-serial device.,
Evgeny Voevodin <=
- [Qemu-devel] [RFC 2/9] virtio: Support transports which can specify the vring alignment, Evgeny Voevodin, 2012/04/25
- [Qemu-devel] [RFC 3/9] Virtio: Add transport bindings., Evgeny Voevodin, 2012/04/25
- [Qemu-devel] [RFC 7/9] hw/virtio-net.c: Add virtio-net device., Evgeny Voevodin, 2012/04/25
- [Qemu-devel] [RFC 8/9] hw/virtio-blk.c: Add virtio-blk device., Evgeny Voevodin, 2012/04/25
- [Qemu-devel] [RFC 6/9] hw/virtio-balloon.c: Add virtio-balloon device., Evgeny Voevodin, 2012/04/25
- [Qemu-devel] [RFC 4/9] Add MMIO based virtio transport, Evgeny Voevodin, 2012/04/25
- [Qemu-devel] [RFC 9/9] hw/exynos4210.c: Create two virtio-mmio transport instances., Evgeny Voevodin, 2012/04/25