2 * virtio ccw scsi implementation
4 * Copyright 2012, 2015 IBM Corp.
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
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"
18 static void virtio_ccw_input_realize(VirtioCcwDevice
*ccw_dev
, Error
**errp
)
20 VirtIOInputCcw
*dev
= VIRTIO_INPUT_CCW(ccw_dev
);
21 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
23 qdev_set_parent_bus(vdev
, BUS(&ccw_dev
->bus
));
24 object_property_set_bool(OBJECT(vdev
), true, "realized", errp
);
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
,
32 DEFINE_PROP_END_OF_LIST(),
35 static void virtio_ccw_input_class_init(ObjectClass
*klass
, void *data
)
37 DeviceClass
*dc
= DEVICE_CLASS(klass
);
38 VirtIOCCWDeviceClass
*k
= VIRTIO_CCW_DEVICE_CLASS(klass
);
40 k
->realize
= virtio_ccw_input_realize
;
41 dc
->props
= virtio_ccw_input_properties
;
42 set_bit(DEVICE_CATEGORY_INPUT
, dc
->categories
);
45 static void virtio_ccw_keyboard_instance_init(Object
*obj
)
47 VirtIOInputHIDCcw
*dev
= VIRTIO_INPUT_HID_CCW(obj
);
48 VirtioCcwDevice
*ccw_dev
= VIRTIO_CCW_DEVICE(obj
);
50 ccw_dev
->force_revision_1
= true;
51 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
52 TYPE_VIRTIO_KEYBOARD
);
55 static void virtio_ccw_mouse_instance_init(Object
*obj
)
57 VirtIOInputHIDCcw
*dev
= VIRTIO_INPUT_HID_CCW(obj
);
58 VirtioCcwDevice
*ccw_dev
= VIRTIO_CCW_DEVICE(obj
);
60 ccw_dev
->force_revision_1
= true;
61 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
65 static void virtio_ccw_tablet_instance_init(Object
*obj
)
67 VirtIOInputHIDCcw
*dev
= VIRTIO_INPUT_HID_CCW(obj
);
68 VirtioCcwDevice
*ccw_dev
= VIRTIO_CCW_DEVICE(obj
);
70 ccw_dev
->force_revision_1
= true;
71 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
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
,
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
),
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
,
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
,
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
,
111 static void virtio_ccw_input_register(void)
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
);
120 type_init(virtio_ccw_input_register
)