From: Kitae Kim Date: Tue, 9 Jul 2013 13:09:09 +0000 (+0900) Subject: virtio-esm: merged virtio-esm. X-Git-Tag: Tizen_Studio_1.3_Release_p2.3.1~900^2~30^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=e67792346a5a313e2153ff4ac6a6412920e843f9;p=sdk%2Femulator%2Fqemu.git virtio-esm: merged virtio-esm. Change-Id: I16023c102e0cd56b0ae852519521d31f0a52f58a Signed-off-by: Kitae Kim --- diff --git a/tizen/src/hw/maru_virtio_esm.c b/tizen/src/hw/maru_virtio_esm.c index 0625f9e344..03c550b083 100644 --- a/tizen/src/hw/maru_virtio_esm.c +++ b/tizen/src/hw/maru_virtio_esm.c @@ -36,7 +36,7 @@ MULTI_DEBUG_CHANNEL(qemu, virtio-esm); #define VIRTIO_ESM_DEVICE_NAME "virtio-guest-status-medium" struct progress_info { - uint16_t percentage; + uint16_t percentage; }; #if 0 @@ -52,7 +52,7 @@ struct progress_info progress; static void virtio_esm_handle(VirtIODevice *vdev, VirtQueue *vq) { - VirtIOESM *vesm = (VirtIOESM *)vdev; + VirtIOESM *vesm = VIRTIO_ESM(vdev); int index = 0; TRACE("virtqueue handler.\n"); @@ -88,36 +88,60 @@ static void virtio_esm_handle(VirtIODevice *vdev, VirtQueue *vq) virtio_notify(&vesm->vdev, vesm->vq); } -static uint32_t virtio_esm_get_features(VirtIODevice *vdev, - uint32_t request_feature) +static void virtio_esm_reset(VirtIODevice *vdev) +{ + TRACE("virtio_esm_reset.\n"); +} + +static uint32_t virtio_esm_get_features(VirtIODevice *vdev, uint32_t feature) { TRACE("virtio_esm_get_features.\n"); - return 0; + return feature; } -VirtIODevice *virtio_esm_init(DeviceState *dev) +static int virtio_esm_device_init(VirtIODevice *vdev) { - VirtIOESM *vesm; - INFO("initialize virtio-esm device\n"); +// DeviceState *qdev = DEVICE(vdev); + VirtIOESM *vesm = VIRTIO_ESM(vdev); - vesm = (VirtIOESM *)virtio_common_init("virtio-esm", - VIRTIO_ID_ESM, 0, sizeof(VirtIOESM)); - if (vesm == NULL) { - ERR("failed to initialize device\n"); - return NULL; - } + INFO("initialize virtio-esm device\n"); + virtio_init(vdev, "virtio-esm", VIRTIO_ID_ESM, 0); - vesm->vdev.get_features = virtio_esm_get_features; - vesm->vq = virtio_add_queue(&vesm->vdev, 1, virtio_esm_handle); - vesm->qdev = dev; + vesm->vq = virtio_add_queue(vdev, 1, virtio_esm_handle); - return &vesm->vdev; + return 0; } -void virtio_esm_exit(VirtIODevice *vdev) +static int virtio_esm_device_exit(DeviceState *dev) { - INFO("destroy device\n"); + VirtIODevice *vdev = VIRTIO_DEVICE(dev); + INFO("destroy device\n"); virtio_cleanup(vdev); + + return 0; +} + +static void virtio_esm_class_init(ObjectClass *klass, void *data) +{ + DeviceClass *dc = DEVICE_CLASS(klass); + VirtioDeviceClass *vdc = VIRTIO_DEVICE_CLASS(klass); + dc->exit = virtio_esm_device_exit; + vdc->init = virtio_esm_device_init; + vdc->get_features = virtio_esm_get_features; + vdc->reset = virtio_esm_reset; +} + +static const TypeInfo virtio_device_info = { + .name = TYPE_VIRTIO_ESM, + .parent = TYPE_VIRTIO_DEVICE, + .instance_size = sizeof(VirtIOESM), + .class_init = virtio_esm_class_init, +}; + +static void virtio_register_types(void) +{ + type_register_static(&virtio_device_info); } +type_init(virtio_register_types)