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