[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [RFC v2 07/12] hw/virtio-serial-bus.c: Add virtio-serial de
From: |
Evgeny Voevodin |
Subject: |
[Qemu-devel] [RFC v2 07/12] hw/virtio-serial-bus.c: Add virtio-serial device. |
Date: |
Mon, 17 Sep 2012 14:00:37 +0400 |
Signed-off-by: Evgeny Voevodin <address@hidden>
---
hw/virtio-serial-bus.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
hw/virtio-serial.h | 11 +++++++++++
2 files changed, 55 insertions(+)
diff --git a/hw/virtio-serial-bus.c b/hw/virtio-serial-bus.c
index 82073f5..699a485 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 {
@@ -1014,3 +1015,46 @@ 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 *s = VIRTIO_SERIAL_FROM_QDEV(dev);
+ vdev = virtio_serial_init(dev, &s->serial);
+ if (!vdev) {
+ return -1;
+ }
+
+ assert(s->trl != NULL);
+
+ return virtio_call_backend_init_cb(dev, s->trl, 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;
+}
+
+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..c6b916a 100644
--- a/hw/virtio-serial.h
+++ b/hw/virtio-serial.h
@@ -15,8 +15,10 @@
#ifndef _QEMU_VIRTIO_SERIAL_H
#define _QEMU_VIRTIO_SERIAL_H
+#include "sysbus.h"
#include "qdev.h"
#include "virtio.h"
+#include "virtio-transport.h"
/* == Interface shared between the guest kernel and qemu == */
@@ -173,6 +175,15 @@ struct VirtIOSerialPort {
bool throttled;
};
+typedef struct {
+ DeviceState qdev;
+ /* virtio-serial */
+ virtio_serial_conf serial;
+ VirtIOTransportLink *trl;
+} VirtIOSerState;
+
+#define VIRTIO_SERIAL_FROM_QDEV(dev) DO_UPCAST(VirtIOSerState, qdev, dev)
+
/* Interface to the virtio-serial bus */
/*
--
1.7.9.5
- [Qemu-devel] [RFC v2 00/12] Virtio-mmio refactoring., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 08/12] hw/virtio-balloon.c: Add virtio-balloon device., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 05/12] hw/pci.c: Make pci_add_option_rom global visible, Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 02/12] virtio: Support transports which can specify the vring alignment, Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 03/12] Virtio: Add transport bindings., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 01/12] virtio: Add support for guest setting of queue size, Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 07/12] hw/virtio-serial-bus.c: Add virtio-serial device.,
Evgeny Voevodin <=
- [Qemu-devel] [RFC v2 06/12] Add MMIO based virtio transport, Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 04/12] hw/qdev-properties.c: Add "transport" property., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 12/12] hw/exynos4210.c: Create two virtio-mmio transport instances., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 09/12] hw/virtio-net.c: Add virtio-net device., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 10/12] hw/virtio-blk.c: Add virtio-blk device., Evgeny Voevodin, 2012/09/17
- [Qemu-devel] [RFC v2 11/12] hw/virtio-pci-new.c: Add VirtIOPCI device., Evgeny Voevodin, 2012/09/17
- Re: [Qemu-devel] [RFC v2 00/12] Virtio-mmio refactoring., KONRAD Frédéric, 2012/09/27