@@ -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
new file mode 100644
@@ -0,0 +1,46 @@
+/*
+ * Virtio transport bindings
+ *
+ * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd.
+ *
+ * Author:
+ * Evgeny Voevodin <e.voevodin@samsung.com>
+ *
+ * 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;
+}
new file mode 100644
@@ -0,0 +1,39 @@
+/*
+ * Virtio transport header
+ *
+ * Copyright (c) 2011 - 2012 Samsung Electronics Co., Ltd.
+ *
+ * Author:
+ * Evgeny Voevodin <e.voevodin@samsung.com>
+ *
+ * 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_ */
Signed-off-by: Evgeny Voevodin <e.voevodin@samsung.com> --- 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