qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [RFC 3/9] Virtio: Add transport bindings.


From: Evgeny Voevodin
Subject: [Qemu-devel] [RFC 3/9] Virtio: Add transport bindings.
Date: Wed, 25 Apr 2012 09:54:11 +0400

Signed-off-by: Evgeny Voevodin <address@hidden>
---
 Makefile.objs         |    1 +
 hw/virtio-transport.c |   46 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/virtio-transport.h |   39 +++++++++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 0 deletions(-)
 create mode 100644 hw/virtio-transport.c
 create mode 100644 hw/virtio-transport.h

diff --git a/Makefile.objs b/Makefile.objs
index 6d6f24d..5a648bc 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -212,6 +212,7 @@ hw-obj-y += vl.o loader.o
 hw-obj-$(CONFIG_VIRTIO) += virtio-console.o
 hw-obj-y += usb/libhw.o
 hw-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
+hw-obj-$(CONFIG_VIRTIO) += virtio-transport.o
 hw-obj-y += fw_cfg.o
 hw-obj-$(CONFIG_PCI) += pci.o pci_bridge.o pci_bridge_dev.o
 hw-obj-$(CONFIG_PCI) += msix.o msi.o
diff --git a/hw/virtio-transport.c b/hw/virtio-transport.c
new file mode 100644
index 0000000..4225a30
--- /dev/null
+++ b/hw/virtio-transport.c
@@ -0,0 +1,46 @@
+/*
+ * Virtio transport bindings
+ *
+ * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd.
+ *
+ * Author:
+ *  Evgeny Voevodin <address@hidden>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#include "virtio-transport.h"
+
+#define VIRTIO_TRANSPORT_BUS "virtio-transport"
+
+struct BusInfo virtio_transport_bus_info = {
+    .name = VIRTIO_TRANSPORT_BUS,
+    .size = sizeof(VirtIOTransportBusState),
+};
+
+int virtio_init_transport(DeviceState *dev, VirtIODevice *vdev)
+{
+    DeviceState *transport_dev = qdev_get_parent_bus(dev)->parent;
+    BusState *bus;
+    VirtIOTransportBusState *virtio_transport_bus;
+
+    /* transport device has single child bus */
+    bus = QLIST_FIRST(&transport_dev->child_bus);
+    virtio_transport_bus = DO_UPCAST(VirtIOTransportBusState, bus, bus);
+
+    if (virtio_transport_bus->init_fn) {
+        return virtio_transport_bus->init_fn(dev, vdev);
+    }
+
+    return 0;
+}
diff --git a/hw/virtio-transport.h b/hw/virtio-transport.h
new file mode 100644
index 0000000..ff39bf7
--- /dev/null
+++ b/hw/virtio-transport.h
@@ -0,0 +1,39 @@
+/*
+ * Virtio transport header
+ *
+ * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd.
+ *
+ * Author:
+ *  Evgeny Voevodin <address@hidden>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License; either version 2
+ * of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, see <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef VIRTIO_TRANSPORT_H_
+#define VIRTIO_TRANSPORT_H_
+
+#include "sysbus.h"
+#include "virtio.h"
+
+extern struct BusInfo virtio_transport_bus_info;
+
+typedef int (*virtio_init_transport_fn)(DeviceState *dev, VirtIODevice *vdev);
+
+typedef struct VirtIOTransportBusState {
+    BusState bus;
+    virtio_init_transport_fn init_fn;
+} VirtIOTransportBusState;
+
+int virtio_init_transport(DeviceState *dev, VirtIODevice *vdev);
+
+#endif /* VIRTIO_TRANSPORT_H_ */
-- 
1.7.5.4




reply via email to

[Prev in Thread] Current Thread [Next in Thread]