#include "range.h"
#ifdef CONFIG_MARU
#include "../tizen/src/hw/maru_device_ids.h"
+#include "../tizen/src/hw/maru_virtio_evdi.h"
#include "../tizen/src/mloop_event.h"
#endif
virtio_exit_pci(pci_dev);
}
+static int virtio_evdi_init_pci(PCIDevice *pci_dev)
+{
+ VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+ VirtIODevice *vdev;
+
+ vdev = virtio_evdi_init(&pci_dev->qdev);
+ if (!vdev) {
+ return -1;
+ }
+ virtio_init_pci(proxy, vdev);
+ return 0;
+}
+
+static void virtio_evdi_exit_pci(PCIDevice *pci_dev)
+{
+ VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev);
+
+ virtio_pci_stop_ioeventfd(proxy);
+ virtio_evdi_exit(proxy->vdev);
+ virtio_exit_pci(pci_dev);
+}
+
#endif
static Property virtio_blk_properties[] = {
.class_init = virtio_hwkey_class_init,
};
+static void virtio_evdi_class_init(ObjectClass *klass, void *data) {
+ DeviceClass *dc = DEVICE_CLASS(klass);
+ PCIDeviceClass *k = PCI_DEVICE_CLASS(klass);
+
+ k->init = virtio_evdi_init_pci;
+ k->exit = virtio_evdi_exit_pci;
+ k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET;
+ k->device_id = PCI_DEVICE_ID_VIRTIO_EVDI;
+ k->revision = VIRTIO_PCI_ABI_VERSION;
+ k->class_id = PCI_CLASS_OTHERS;
+ dc->reset = virtio_pci_reset;
+}
+
+static TypeInfo virtio_evdi_info = {
+ .name = "virtio-evdi-pci",
+ .parent = TYPE_PCI_DEVICE,
+ .instance_size = sizeof(VirtIOPCIProxy),
+ .class_init = virtio_evdi_class_init,
+};
+
+
#endif /* CONFIG_MARU */
static void virtio_pci_register_types(void)
type_register_static(&virtio_keyboard_info);
type_register_static(&virtio_esm_info);
type_register_static(&virtio_hwkey_info);
+ type_register_static(&virtio_evdi_info);
#endif
}
--- /dev/null
+/*\r
+ * Virtio EmulatorVirtualDeviceInterface Device\r
+ *\r
+ * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved\r
+ *\r
+ * Contact:\r
+ * DaiYoung Kim <daiyoung777.kim.hwang@samsung.com>\r
+ * YeongKyoon Lee <yeongkyoon.lee@samsung.com>\r
+ *\r
+ * This program is free software; you can redistribute it and/or\r
+ * modify it under the terms of the GNU General Public License\r
+ * as published by the Free Software Foundation; either version 2\r
+ * of the License, or (at your option) any later version.\r
+ *\r
+ * This program is distributed in the hope that it will be useful,\r
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\r
+ * GNU General Public License for more details.\r
+ *\r
+ * You should have received a copy of the GNU General Public License\r
+ * along with this program; if not, write to the Free Software\r
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.\r
+ *\r
+ * Contributors:\r
+ * - S-Core Co., Ltd\r
+ *\r
+ */\r
+\r
+#include "maru_device_ids.h"\r
+#include "maru_virtio_evdi.h"\r
+#include "debug_ch.h"\r
+\r
+MULTI_DEBUG_CHANNEL(qemu, virtio-evdi);\r
+\r
+#define VIRTIO_EVDI_DEVICE_NAME "virtio-evdi"\r
+\r
+#define __MAX_BUF_SIZE 1024\r
+\r
+enum {\r
+ IOTYPE_INPUT = 0,\r
+ IOTYPE_OUTPUT = 1\r
+};\r
+\r
+struct msg_info {\r
+ char buf[__MAX_BUF_SIZE];\r
+ uint32_t use;\r
+};\r
+\r
+typedef struct VirtIO_EVDI{\r
+ VirtIODevice vdev;\r
+ VirtQueue *rvq;\r
+ VirtQueue *svq;\r
+ DeviceState *qdev;\r
+\r
+ QEMUBH *bh;\r
+} VirtIO_EVDI;\r
+\r
+\r
+VirtIO_EVDI* vio_evdi;\r
+\r
+static int g_cnt = 0;\r
+\r
+static void virtio_evdi_recv(VirtIODevice *vdev, VirtQueue *vq)\r
+{\r
+ int index = 0;\r
+\r
+ struct msg_info _msg;\r
+\r
+ INFO(">> evdirecv : virtio_evdi_recv\n");\r
+\r
+ if (unlikely(virtio_queue_empty(vio_evdi->rvq))) {\r
+ INFO(">> evdirecv : virtqueue is empty\n");\r
+ return;\r
+ }\r
+\r
+ VirtQueueElement elem;\r
+\r
+ while ((index = virtqueue_pop(vq, &elem))) {\r
+\r
+ INFO(">> evdirecv : virtqueue_pop. index: %d\n", index);\r
+ INFO(">> evdirecv : element out_num : %d, in_num : %d\n", elem.out_num, elem.in_num);\r
+\r
+ if (index == 0) {\r
+ INFO("evdirecv : virtqueue break\n");\r
+ break;\r
+ }\r
+\r
+ INFO(">> evdirecv : received use = %d, iov_len = %d\n", _msg.use, elem.in_sg[0].iov_len);\r
+\r
+ memcpy(&_msg, elem.in_sg[0].iov_base, elem.in_sg[0].iov_len);\r
+\r
+\r
+ if (g_cnt < 10)\r
+ {\r
+ memset(&_msg, 0x00, sizeof(_msg));\r
+ sprintf(_msg.buf, "test_%d\n", g_cnt++);\r
+ memcpy(elem.in_sg[0].iov_base, &_msg, sizeof(struct msg_info));\r
+\r
+ INFO(">> evdirecv : send to guest msg use = %d, msg = %s, iov_len = %d \n",\r
+ _msg.use, _msg.buf, elem.in_sg[0].iov_len);\r
+\r
+\r
+ virtqueue_push(vq, &elem, sizeof(VirtIO_EVDI));\r
+ virtio_notify(&vio_evdi->vdev, vq);\r
+ }\r
+ }\r
+\r
+ INFO("enf of virtio_evdi_recv\n");\r
+}\r
+\r
+\r
+static void virtio_evdi_send(VirtIODevice *vdev, VirtQueue *vq)\r
+{\r
+ VirtIO_EVDI *vevdi = (VirtIO_EVDI *)vdev;\r
+ int index = 0;\r
+ struct msg_info _msg;\r
+\r
+ INFO("<< evdisend : virtio_evdi_send \n");\r
+ if (virtio_queue_empty(vevdi->svq)) {\r
+ INFO("<< evdisend : virtqueue is empty.\n");\r
+ return;\r
+ }\r
+\r
+ VirtQueueElement elem;\r
+\r
+ while ((index = virtqueue_pop(vq, &elem))) {\r
+\r
+ INFO("<< evdisend : virtqueue pop. index: %d\n", index);\r
+ INFO("<< evdisend : element out_num : %d, in_num : %d\n", elem.out_num, elem.in_num);\r
+\r
+ if (index == 0) {\r
+ INFO("<< evdisend : virtqueue break\n");\r
+ break;\r
+ }\r
+\r
+ INFO("<< evdisend : use=%d, iov_len = %d\n", _msg.use, elem.out_sg[0].iov_len);\r
+\r
+ memset(&_msg, 0x00, sizeof(_msg));\r
+ memcpy(&_msg, elem.out_sg[0].iov_base, elem.out_sg[0].iov_len);\r
+\r
+ INFO("<< evdisend : recv from guest len = %d, msg = %s \n", _msg.use, _msg.buf);\r
+ }\r
+\r
+ virtqueue_push(vq, &elem, sizeof(VirtIO_EVDI));\r
+ virtio_notify(&vio_evdi->vdev, vq);\r
+}\r
+\r
+static void maru_virtio_evdi_notify(void)\r
+{\r
+ TRACE("nothing to do.\n");\r
+}\r
+\r
+static uint32_t virtio_evdi_get_features(VirtIODevice *vdev,\r
+ uint32_t request_feature)\r
+{\r
+ TRACE("virtio_evdi_get_features.\n");\r
+ return 0;\r
+}\r
+\r
+static void maru_evdi_bh(void *opaque)\r
+{\r
+ maru_virtio_evdi_notify();\r
+}\r
+\r
+VirtIODevice *virtio_evdi_init(DeviceState *dev)\r
+{\r
+ INFO("initialize evdi device\n");\r
+\r
+ vio_evdi = (VirtIO_EVDI *)virtio_common_init(VIRTIO_EVDI_DEVICE_NAME,\r
+ VIRTIO_ID_EVDI, 0, sizeof(VirtIO_EVDI));\r
+ if (vio_evdi == NULL) {\r
+ ERR("failed to initialize evdi device\n");\r
+ return NULL;\r
+ }\r
+\r
+ vio_evdi->vdev.get_features = virtio_evdi_get_features;\r
+ vio_evdi->rvq = virtio_add_queue(&vio_evdi->vdev, 256, virtio_evdi_recv);\r
+ vio_evdi->svq = virtio_add_queue(&vio_evdi->vdev, 256, virtio_evdi_send);\r
+ vio_evdi->qdev = dev;\r
+\r
+ vio_evdi->bh = qemu_bh_new(maru_evdi_bh, vio_evdi);\r
+\r
+ return &vio_evdi->vdev;\r
+}\r
+\r
+void virtio_evdi_exit(VirtIODevice *vdev)\r
+{\r
+ INFO("destroy evdi device\n");\r
+\r
+ if (vio_evdi->bh) {\r
+ qemu_bh_delete(vio_evdi->bh);\r
+ }\r
+\r
+ virtio_cleanup(vdev);\r
+}\r
+\r