From: syeon.hwang Date: Wed, 12 Dec 2012 08:24:53 +0000 (+0900) Subject: virtio-esm: First introduce of virtio-esm X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~1294 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=b6b19918927aa7ebc48d52285e5bb3bd550c5097;p=sdk%2Femulator%2Fqemu.git virtio-esm: First introduce of virtio-esm Introduce "Maru VirtIO EmulatorStatusMedium" for represent boot up progress. Signed-off-by: SeokYeon Hwang --- diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c index d8b41bb22e..8ff80d9319 100644 --- a/hw/virtio-pci.c +++ b/hw/virtio-pci.c @@ -948,6 +948,28 @@ static void virtio_keyboard_exit_pci(PCIDevice *pci_dev) virtio_keyboard_exit(proxy->vdev); virtio_exit_pci(pci_dev); } + +static int virtio_esm_init_pci(PCIDevice *pci_dev) +{ + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); + VirtIODevice *vdev; + + vdev = virtio_esm_init(&pci_dev->qdev); + if (!vdev) { + return -1; + } + virtio_init_pci(proxy, vdev); + return 0; +} + +static void virtio_esm_exit_pci(PCIDevice *pci_dev) +{ + VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); + + virtio_pci_stop_ioeventfd(proxy); + virtio_esm_exit(proxy->vdev); + virtio_exit_pci(pci_dev); +} #endif static Property virtio_blk_properties[] = { @@ -1184,8 +1206,7 @@ static TypeInfo maru_virtio_touchscreen_info = { .class_init = maru_virtio_touchscreen_class_init, }; -static void virtio_keyboard_class_init(ObjectClass *klass, void *data) -{ +static void virtio_keyboard_class_init(ObjectClass *klass, void *data) { DeviceClass *dc = DEVICE_CLASS(klass); PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); @@ -1204,6 +1225,26 @@ static TypeInfo virtio_keyboard_info = { .instance_size = sizeof(VirtIOPCIProxy), .class_init = virtio_keyboard_class_init, }; + +static void virtio_esm_class_init(ObjectClass *klass, void *data) { + DeviceClass *dc = DEVICE_CLASS(klass); + PCIDeviceClass *k = PCI_DEVICE_CLASS(klass); + + k->init = virtio_esm_init_pci; + k->exit = virtio_esm_exit_pci; + k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + k->device_id = PCI_DEVICE_ID_VIRTIO_ESM; + k->revision = VIRTIO_PCI_ABI_VERSION; + k->class_id = PCI_CLASS_OTHERS; + dc->reset = virtio_pci_reset; +} + +static TypeInfo virtio_esm_info = { + .name = "virtio-esm-pci", + .parent = TYPE_PCI_DEVICE, + .instance_size = sizeof(VirtIOPCIProxy), + .class_init = virtio_esm_class_init, +}; #endif /* CONFIG_MARU */ static void virtio_pci_register_types(void) @@ -1219,6 +1260,7 @@ static void virtio_pci_register_types(void) #ifdef CONFIG_MARU type_register_static(&maru_virtio_touchscreen_info); type_register_static(&virtio_keyboard_info); + type_register_static(&virtio_esm_info); #endif } diff --git a/tizen/src/Makefile.tizen b/tizen/src/Makefile.tizen index e678bbd074..bd99391f01 100755 --- a/tizen/src/Makefile.tizen +++ b/tizen/src/Makefile.tizen @@ -98,6 +98,7 @@ obj-y += maru_brightness.o obj-y += maru_usb_touchscreen.o maru_virtio_touchscreen.o obj-y += maru_virtio_keyboard.o obj-y += maru_codec.o +obj-y += maru_virtio_esm.o obj-$(CONFIG_PCI) += maru_camera_common_pci.o obj-$(CONFIG_LINUX) += maru_camera_linux_pci.o diff --git a/tizen/src/hw/maru_device_ids.h b/tizen/src/hw/maru_device_ids.h index 0049917684..6f6530cd1c 100644 --- a/tizen/src/hw/maru_device_ids.h +++ b/tizen/src/hw/maru_device_ids.h @@ -50,6 +50,7 @@ /* Device ID 0x1000 through 0x103F inclusive is a virtio device */ #define PCI_DEVICE_ID_VIRTIO_TOUCHSCREEN 0x101D #define PCI_DEVICE_ID_VIRTIO_KEYBOARD 0x1020 +#define PCI_DEVICE_ID_VIRTIO_ESM 0x1024 /* Virtio */ /* @@ -80,5 +81,6 @@ */ #define VIRTIO_ID_TOUCHSCREEN 11 #define VIRTIO_ID_KEYBOARD 12 +#define VIRTIO_ID_ESM 13 #endif /* MARU_DEVICE_IDS_H_ */ diff --git a/tizen/src/hw/maru_virtio_esm.c b/tizen/src/hw/maru_virtio_esm.c new file mode 100644 index 0000000000..5969c4024f --- /dev/null +++ b/tizen/src/hw/maru_virtio_esm.c @@ -0,0 +1,120 @@ +/* + * Virtio EmulatorStatusMedium Device + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: + * SeokYeon Hwang + * YeongKyoon Lee + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#include "maru_device_ids.h" +#include "maru_virtio_esm.h" +#include "tizen/src/debug_ch.h" + +MULTI_DEBUG_CHANNEL(qemu, virtio-esm); + +#define VIRTIO_ESM_DEVICE_NAME "virtio-guest-status-medium" + +struct progress_info { + uint16_t percentage; +}; + +typedef struct VirtIOEmulatorStatusMedium { + VirtIODevice vdev; + VirtQueue *vq; + DeviceState *qdev; +} VirtIO_ESM; + +static VirtQueueElement elem; +struct progress_info progress; + +static void virtio_esm_handle(VirtIODevice *vdev, VirtQueue *vq) +{ + VirtIO_ESM *vesm = (VirtIO_ESM *)vdev; + int index = 0; + + TRACE("virtqueue handler.\n"); + if (virtio_queue_empty(vesm->vq)) { + INFO("virtqueue is empty.\n"); + return; + } + + // Get a queue buffer. + index = virtqueue_pop(vq, &elem); + TRACE("virtqueue pop. index: %d\n", index); + + TRACE("virtio element out number : %d\n", elem.out_num); + if (elem.out_num != 1) { + ERR("virtio element out number is wierd."); + } + else { + TRACE("caramis elem.out_sg[0].iov_len : %x\n", elem.out_sg[0].iov_len); + TRACE("caramis elem.out_sg[0].iov_base : %x\n", elem.out_sg[0].iov_base); + if (elem.out_sg[0].iov_len != 2) { + ERR("out lenth is wierd."); + } + else { + progress.percentage = *((uint16_t*)elem.out_sg[0].iov_base); + INFO("boot up progress is [%u] percent done.\n", progress.percentage); + // notify to skin + notify_booting_progress(progress.percentage); + } + } + + // There is no data to copy into guest. + virtqueue_push(vesm->vq, &elem, 0); + virtio_notify(&vesm->vdev, vesm->vq); +} + +static uint32_t virtio_esm_get_features(VirtIODevice *vdev, + uint32_t request_feature) +{ + TRACE("virtio_esm_get_features.\n"); + return 0; +} + +VirtIODevice *virtio_esm_init(DeviceState *dev) +{ + VirtIO_ESM *vesm; + INFO("initialize virtio-esm device\n"); + + vesm = (VirtIO_ESM *)virtio_common_init("virtio-esm", + VIRTIO_ID_ESM, 0, sizeof(VirtIO_ESM)); + if (vesm == NULL) { + ERR("failed to initialize device\n"); + return NULL; + } + + vesm->vdev.get_features = virtio_esm_get_features; + vesm->vq = virtio_add_queue(&vesm->vdev, 1, virtio_esm_handle); + vesm->qdev = dev; + + return &vesm->vdev; +} + +void virtio_esm_exit(VirtIODevice *vdev) +{ + INFO("destroy device\n"); + + virtio_cleanup(vdev); +} + diff --git a/tizen/src/hw/maru_virtio_esm.h b/tizen/src/hw/maru_virtio_esm.h new file mode 100644 index 0000000000..987ea9a985 --- /dev/null +++ b/tizen/src/hw/maru_virtio_esm.h @@ -0,0 +1,47 @@ +/* + * Virtio EmulatorStatusMedium Device + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd All Rights Reserved + * + * Contact: + * SeokYeon Hwang + * YeongKyoon Lee + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * as published by the Free Software Foundation; 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, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * + * Contributors: + * - S-Core Co., Ltd + * + */ + +#ifndef MARU_VIRTIO_ESM_H_ +#define MARU_VIRTIO_ESM_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include "hw.h" +#include "virtio.h" + +VirtIODevice *virtio_esm_init(DeviceState *dev); + +void virtio_esm_exit(VirtIODevice *vdev); + +#ifdef __cplusplus +} +#endif + +#endif /* MARU_VIRTIO_ESM_H_ */