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/qdev-properties.h" 13 #include "hw/virtio/virtio.h" 14 #include "qapi/error.h" 15 #include "qemu/module.h" 16 #include "virtio-ccw.h" 17 18 static void virtio_ccw_input_realize(VirtioCcwDevice *ccw_dev, Error **errp) 19 { 20 VirtIOInputCcw *dev = VIRTIO_INPUT_CCW(ccw_dev); 21 DeviceState *vdev = DEVICE(&dev->vdev); 22 23 qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 24 object_property_set_bool(OBJECT(vdev), true, "realized", errp); 25 } 26 27 static Property virtio_ccw_input_properties[] = { 28 DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 29 VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 30 DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 31 VIRTIO_CCW_MAX_REV), 32 DEFINE_PROP_END_OF_LIST(), 33 }; 34 35 static void virtio_ccw_input_class_init(ObjectClass *klass, void *data) 36 { 37 DeviceClass *dc = DEVICE_CLASS(klass); 38 VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 39 40 k->realize = virtio_ccw_input_realize; 41 device_class_set_props(dc, virtio_ccw_input_properties); 42 set_bit(DEVICE_CATEGORY_INPUT, dc->categories); 43 } 44 45 static void virtio_ccw_keyboard_instance_init(Object *obj) 46 { 47 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 48 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 49 50 ccw_dev->force_revision_1 = true; 51 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 52 TYPE_VIRTIO_KEYBOARD); 53 } 54 55 static void virtio_ccw_mouse_instance_init(Object *obj) 56 { 57 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 58 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 59 60 ccw_dev->force_revision_1 = true; 61 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 62 TYPE_VIRTIO_MOUSE); 63 } 64 65 static void virtio_ccw_tablet_instance_init(Object *obj) 66 { 67 VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 68 VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 69 70 ccw_dev->force_revision_1 = true; 71 virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 72 TYPE_VIRTIO_TABLET); 73 } 74 75 static const TypeInfo virtio_ccw_input = { 76 .name = TYPE_VIRTIO_INPUT_CCW, 77 .parent = TYPE_VIRTIO_CCW_DEVICE, 78 .instance_size = sizeof(VirtIOInputCcw), 79 .class_init = virtio_ccw_input_class_init, 80 .abstract = true, 81 }; 82 83 static const TypeInfo virtio_ccw_input_hid = { 84 .name = TYPE_VIRTIO_INPUT_HID_CCW, 85 .parent = TYPE_VIRTIO_INPUT_CCW, 86 .instance_size = sizeof(VirtIOInputHIDCcw), 87 .abstract = true, 88 }; 89 90 static const TypeInfo virtio_ccw_keyboard = { 91 .name = TYPE_VIRTIO_KEYBOARD_CCW, 92 .parent = TYPE_VIRTIO_INPUT_HID_CCW, 93 .instance_size = sizeof(VirtIOInputHIDCcw), 94 .instance_init = virtio_ccw_keyboard_instance_init, 95 }; 96 97 static const TypeInfo virtio_ccw_mouse = { 98 .name = TYPE_VIRTIO_MOUSE_CCW, 99 .parent = TYPE_VIRTIO_INPUT_HID_CCW, 100 .instance_size = sizeof(VirtIOInputHIDCcw), 101 .instance_init = virtio_ccw_mouse_instance_init, 102 }; 103 104 static const TypeInfo virtio_ccw_tablet = { 105 .name = TYPE_VIRTIO_TABLET_CCW, 106 .parent = TYPE_VIRTIO_INPUT_HID_CCW, 107 .instance_size = sizeof(VirtIOInputHIDCcw), 108 .instance_init = virtio_ccw_tablet_instance_init, 109 }; 110 111 static void virtio_ccw_input_register(void) 112 { 113 type_register_static(&virtio_ccw_input); 114 type_register_static(&virtio_ccw_input_hid); 115 type_register_static(&virtio_ccw_keyboard); 116 type_register_static(&virtio_ccw_mouse); 117 type_register_static(&virtio_ccw_tablet); 118 } 119 120 type_init(virtio_ccw_input_register) 121