qemu/hw/s390x/virtio-ccw-input.c
<<
>>
Prefs
   1/*
   2 * virtio ccw scsi implementation
   3 *
   4 * Copyright 2012, 2015 IBM Corp.
   5 *
   6 * This work is licensed under the terms of the GNU GPL, version 2 or (at
   7 * your option) any later version. See the COPYING file in the top-level
   8 * directory.
   9 */
  10
  11#include "qemu/osdep.h"
  12#include "hw/virtio/virtio.h"
  13#include "qapi/error.h"
  14#include "virtio-ccw.h"
  15
  16static void virtio_ccw_input_realize(VirtioCcwDevice *ccw_dev, Error **errp)
  17{
  18    VirtIOInputCcw *dev = VIRTIO_INPUT_CCW(ccw_dev);
  19    DeviceState *vdev = DEVICE(&dev->vdev);
  20
  21    qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus));
  22    object_property_set_bool(OBJECT(vdev), true, "realized", errp);
  23}
  24
  25static Property virtio_ccw_input_properties[] = {
  26    DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
  27                    VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
  28    DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
  29                       VIRTIO_CCW_MAX_REV),
  30    DEFINE_PROP_END_OF_LIST(),
  31};
  32
  33static void virtio_ccw_input_class_init(ObjectClass *klass, void *data)
  34{
  35    DeviceClass *dc = DEVICE_CLASS(klass);
  36    VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
  37
  38    k->realize = virtio_ccw_input_realize;
  39    dc->props = virtio_ccw_input_properties;
  40    set_bit(DEVICE_CATEGORY_INPUT, dc->categories);
  41}
  42
  43static void virtio_ccw_keyboard_instance_init(Object *obj)
  44{
  45    VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
  46    VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
  47
  48    ccw_dev->force_revision_1 = true;
  49    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
  50                                TYPE_VIRTIO_KEYBOARD);
  51}
  52
  53static void virtio_ccw_mouse_instance_init(Object *obj)
  54{
  55    VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
  56    VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
  57
  58    ccw_dev->force_revision_1 = true;
  59    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
  60                                TYPE_VIRTIO_MOUSE);
  61}
  62
  63static void virtio_ccw_tablet_instance_init(Object *obj)
  64{
  65    VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj);
  66    VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj);
  67
  68    ccw_dev->force_revision_1 = true;
  69    virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
  70                                TYPE_VIRTIO_TABLET);
  71}
  72
  73static const TypeInfo virtio_ccw_input = {
  74    .name          = TYPE_VIRTIO_INPUT_CCW,
  75    .parent        = TYPE_VIRTIO_CCW_DEVICE,
  76    .instance_size = sizeof(VirtIOInputCcw),
  77    .class_init    = virtio_ccw_input_class_init,
  78    .abstract = true,
  79};
  80
  81static const TypeInfo virtio_ccw_input_hid = {
  82    .name          = TYPE_VIRTIO_INPUT_HID_CCW,
  83    .parent        = TYPE_VIRTIO_INPUT_CCW,
  84    .instance_size = sizeof(VirtIOInputHIDCcw),
  85    .abstract = true,
  86};
  87
  88static const TypeInfo virtio_ccw_keyboard = {
  89    .name          = TYPE_VIRTIO_KEYBOARD_CCW,
  90    .parent        = TYPE_VIRTIO_INPUT_HID_CCW,
  91    .instance_size = sizeof(VirtIOInputHIDCcw),
  92    .instance_init = virtio_ccw_keyboard_instance_init,
  93};
  94
  95static const TypeInfo virtio_ccw_mouse = {
  96    .name          = TYPE_VIRTIO_MOUSE_CCW,
  97    .parent        = TYPE_VIRTIO_INPUT_HID_CCW,
  98    .instance_size = sizeof(VirtIOInputHIDCcw),
  99    .instance_init = virtio_ccw_mouse_instance_init,
 100};
 101
 102static const TypeInfo virtio_ccw_tablet = {
 103    .name          = TYPE_VIRTIO_TABLET_CCW,
 104    .parent        = TYPE_VIRTIO_INPUT_HID_CCW,
 105    .instance_size = sizeof(VirtIOInputHIDCcw),
 106    .instance_init = virtio_ccw_tablet_instance_init,
 107};
 108
 109static void virtio_ccw_input_register(void)
 110{
 111    type_register_static(&virtio_ccw_input);
 112    type_register_static(&virtio_ccw_input_hid);
 113    type_register_static(&virtio_ccw_keyboard);
 114    type_register_static(&virtio_ccw_mouse);
 115    type_register_static(&virtio_ccw_tablet);
 116}
 117
 118type_init(virtio_ccw_input_register)
 119