190b90a0fSThomas Huth /* 290b90a0fSThomas Huth * virtio ccw scsi implementation 390b90a0fSThomas Huth * 490b90a0fSThomas Huth * Copyright 2012, 2015 IBM Corp. 590b90a0fSThomas Huth * 690b90a0fSThomas Huth * This work is licensed under the terms of the GNU GPL, version 2 or (at 790b90a0fSThomas Huth * your option) any later version. See the COPYING file in the top-level 890b90a0fSThomas Huth * directory. 990b90a0fSThomas Huth */ 1090b90a0fSThomas Huth 1190b90a0fSThomas Huth #include "qemu/osdep.h" 1290b90a0fSThomas Huth #include "hw/virtio/virtio.h" 1390b90a0fSThomas Huth #include "qapi/error.h" 14*0b8fa32fSMarkus Armbruster #include "qemu/module.h" 1590b90a0fSThomas Huth #include "virtio-ccw.h" 1690b90a0fSThomas Huth 1790b90a0fSThomas Huth static void virtio_ccw_input_realize(VirtioCcwDevice *ccw_dev, Error **errp) 1890b90a0fSThomas Huth { 1990b90a0fSThomas Huth VirtIOInputCcw *dev = VIRTIO_INPUT_CCW(ccw_dev); 2090b90a0fSThomas Huth DeviceState *vdev = DEVICE(&dev->vdev); 2190b90a0fSThomas Huth 2290b90a0fSThomas Huth qdev_set_parent_bus(vdev, BUS(&ccw_dev->bus)); 2390b90a0fSThomas Huth object_property_set_bool(OBJECT(vdev), true, "realized", errp); 2490b90a0fSThomas Huth } 2590b90a0fSThomas Huth 2690b90a0fSThomas Huth static Property virtio_ccw_input_properties[] = { 2790b90a0fSThomas Huth DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags, 2890b90a0fSThomas Huth VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true), 2990b90a0fSThomas Huth DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev, 3090b90a0fSThomas Huth VIRTIO_CCW_MAX_REV), 3190b90a0fSThomas Huth DEFINE_PROP_END_OF_LIST(), 3290b90a0fSThomas Huth }; 3390b90a0fSThomas Huth 3490b90a0fSThomas Huth static void virtio_ccw_input_class_init(ObjectClass *klass, void *data) 3590b90a0fSThomas Huth { 3690b90a0fSThomas Huth DeviceClass *dc = DEVICE_CLASS(klass); 3790b90a0fSThomas Huth VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass); 3890b90a0fSThomas Huth 3990b90a0fSThomas Huth k->realize = virtio_ccw_input_realize; 4090b90a0fSThomas Huth dc->props = virtio_ccw_input_properties; 4190b90a0fSThomas Huth set_bit(DEVICE_CATEGORY_INPUT, dc->categories); 4290b90a0fSThomas Huth } 4390b90a0fSThomas Huth 4490b90a0fSThomas Huth static void virtio_ccw_keyboard_instance_init(Object *obj) 4590b90a0fSThomas Huth { 4690b90a0fSThomas Huth VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 4790b90a0fSThomas Huth VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 4890b90a0fSThomas Huth 4990b90a0fSThomas Huth ccw_dev->force_revision_1 = true; 5090b90a0fSThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 5190b90a0fSThomas Huth TYPE_VIRTIO_KEYBOARD); 5290b90a0fSThomas Huth } 5390b90a0fSThomas Huth 5490b90a0fSThomas Huth static void virtio_ccw_mouse_instance_init(Object *obj) 5590b90a0fSThomas Huth { 5690b90a0fSThomas Huth VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 5790b90a0fSThomas Huth VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 5890b90a0fSThomas Huth 5990b90a0fSThomas Huth ccw_dev->force_revision_1 = true; 6090b90a0fSThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 6190b90a0fSThomas Huth TYPE_VIRTIO_MOUSE); 6290b90a0fSThomas Huth } 6390b90a0fSThomas Huth 6490b90a0fSThomas Huth static void virtio_ccw_tablet_instance_init(Object *obj) 6590b90a0fSThomas Huth { 6690b90a0fSThomas Huth VirtIOInputHIDCcw *dev = VIRTIO_INPUT_HID_CCW(obj); 6790b90a0fSThomas Huth VirtioCcwDevice *ccw_dev = VIRTIO_CCW_DEVICE(obj); 6890b90a0fSThomas Huth 6990b90a0fSThomas Huth ccw_dev->force_revision_1 = true; 7090b90a0fSThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev), 7190b90a0fSThomas Huth TYPE_VIRTIO_TABLET); 7290b90a0fSThomas Huth } 7390b90a0fSThomas Huth 7490b90a0fSThomas Huth static const TypeInfo virtio_ccw_input = { 7590b90a0fSThomas Huth .name = TYPE_VIRTIO_INPUT_CCW, 7690b90a0fSThomas Huth .parent = TYPE_VIRTIO_CCW_DEVICE, 7790b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputCcw), 7890b90a0fSThomas Huth .class_init = virtio_ccw_input_class_init, 7990b90a0fSThomas Huth .abstract = true, 8090b90a0fSThomas Huth }; 8190b90a0fSThomas Huth 8290b90a0fSThomas Huth static const TypeInfo virtio_ccw_input_hid = { 8390b90a0fSThomas Huth .name = TYPE_VIRTIO_INPUT_HID_CCW, 8490b90a0fSThomas Huth .parent = TYPE_VIRTIO_INPUT_CCW, 8590b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputHIDCcw), 8690b90a0fSThomas Huth .abstract = true, 8790b90a0fSThomas Huth }; 8890b90a0fSThomas Huth 8990b90a0fSThomas Huth static const TypeInfo virtio_ccw_keyboard = { 9090b90a0fSThomas Huth .name = TYPE_VIRTIO_KEYBOARD_CCW, 9190b90a0fSThomas Huth .parent = TYPE_VIRTIO_INPUT_HID_CCW, 9290b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputHIDCcw), 9390b90a0fSThomas Huth .instance_init = virtio_ccw_keyboard_instance_init, 9490b90a0fSThomas Huth }; 9590b90a0fSThomas Huth 9690b90a0fSThomas Huth static const TypeInfo virtio_ccw_mouse = { 9790b90a0fSThomas Huth .name = TYPE_VIRTIO_MOUSE_CCW, 9890b90a0fSThomas Huth .parent = TYPE_VIRTIO_INPUT_HID_CCW, 9990b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputHIDCcw), 10090b90a0fSThomas Huth .instance_init = virtio_ccw_mouse_instance_init, 10190b90a0fSThomas Huth }; 10290b90a0fSThomas Huth 10390b90a0fSThomas Huth static const TypeInfo virtio_ccw_tablet = { 10490b90a0fSThomas Huth .name = TYPE_VIRTIO_TABLET_CCW, 10590b90a0fSThomas Huth .parent = TYPE_VIRTIO_INPUT_HID_CCW, 10690b90a0fSThomas Huth .instance_size = sizeof(VirtIOInputHIDCcw), 10790b90a0fSThomas Huth .instance_init = virtio_ccw_tablet_instance_init, 10890b90a0fSThomas Huth }; 10990b90a0fSThomas Huth 11090b90a0fSThomas Huth static void virtio_ccw_input_register(void) 11190b90a0fSThomas Huth { 11290b90a0fSThomas Huth type_register_static(&virtio_ccw_input); 11390b90a0fSThomas Huth type_register_static(&virtio_ccw_input_hid); 11490b90a0fSThomas Huth type_register_static(&virtio_ccw_keyboard); 11590b90a0fSThomas Huth type_register_static(&virtio_ccw_mouse); 11690b90a0fSThomas Huth type_register_static(&virtio_ccw_tablet); 11790b90a0fSThomas Huth } 11890b90a0fSThomas Huth 11990b90a0fSThomas Huth type_init(virtio_ccw_input_register) 120