xref: /openbmc/qemu/hw/s390x/virtio-ccw-blk.c (revision 2c471a8291c182130a77702d9bd4c910d987c6a9)
1331cf66eSThomas Huth /*
2331cf66eSThomas Huth  * virtio ccw block implementation
3331cf66eSThomas Huth  *
4331cf66eSThomas Huth  * Copyright 2012, 2015 IBM Corp.
5331cf66eSThomas Huth  * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com>
6331cf66eSThomas Huth  *
7331cf66eSThomas Huth  * This work is licensed under the terms of the GNU GPL, version 2 or (at
8331cf66eSThomas Huth  * your option) any later version. See the COPYING file in the top-level
9331cf66eSThomas Huth  * directory.
10331cf66eSThomas Huth  */
11331cf66eSThomas Huth 
12331cf66eSThomas Huth #include "qemu/osdep.h"
13a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
14331cf66eSThomas Huth #include "hw/virtio/virtio.h"
15331cf66eSThomas Huth #include "qapi/error.h"
160b8fa32fSMarkus Armbruster #include "qemu/module.h"
17331cf66eSThomas Huth #include "virtio-ccw.h"
187da50d64SPaolo Bonzini #include "hw/virtio/virtio-blk.h"
197da50d64SPaolo Bonzini 
207da50d64SPaolo Bonzini #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw"
217da50d64SPaolo Bonzini OBJECT_DECLARE_SIMPLE_TYPE(VirtIOBlkCcw, VIRTIO_BLK_CCW)
227da50d64SPaolo Bonzini 
237da50d64SPaolo Bonzini struct VirtIOBlkCcw {
247da50d64SPaolo Bonzini     VirtioCcwDevice parent_obj;
257da50d64SPaolo Bonzini     VirtIOBlock vdev;
267da50d64SPaolo Bonzini };
27331cf66eSThomas Huth 
virtio_ccw_blk_realize(VirtioCcwDevice * ccw_dev,Error ** errp)28331cf66eSThomas Huth static void virtio_ccw_blk_realize(VirtioCcwDevice *ccw_dev, Error **errp)
29331cf66eSThomas Huth {
30331cf66eSThomas Huth     VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(ccw_dev);
31331cf66eSThomas Huth     DeviceState *vdev = DEVICE(&dev->vdev);
32331cf66eSThomas Huth 
3399ba777eSMarkus Armbruster     qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
34331cf66eSThomas Huth }
35331cf66eSThomas Huth 
virtio_ccw_blk_instance_init(Object * obj)36331cf66eSThomas Huth static void virtio_ccw_blk_instance_init(Object *obj)
37331cf66eSThomas Huth {
38331cf66eSThomas Huth     VirtIOBlkCcw *dev = VIRTIO_BLK_CCW(obj);
39331cf66eSThomas Huth 
40331cf66eSThomas Huth     virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
41331cf66eSThomas Huth                                 TYPE_VIRTIO_BLK);
42331cf66eSThomas Huth     object_property_add_alias(obj, "bootindex", OBJECT(&dev->vdev),
43d2623129SMarkus Armbruster                               "bootindex");
44331cf66eSThomas Huth }
45331cf66eSThomas Huth 
46331cf66eSThomas Huth static Property virtio_ccw_blk_properties[] = {
47331cf66eSThomas Huth     DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
48331cf66eSThomas Huth                     VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
49331cf66eSThomas Huth     DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
50331cf66eSThomas Huth                        VIRTIO_CCW_MAX_REV),
51*6e7c96aeSThomas Huth     DEFINE_PROP_CCW_LOADPARM("loadparm", CcwDevice, loadparm),
52331cf66eSThomas Huth     DEFINE_PROP_END_OF_LIST(),
53331cf66eSThomas Huth };
54331cf66eSThomas Huth 
virtio_ccw_blk_class_init(ObjectClass * klass,void * data)55331cf66eSThomas Huth static void virtio_ccw_blk_class_init(ObjectClass *klass, void *data)
56331cf66eSThomas Huth {
57331cf66eSThomas Huth     DeviceClass *dc = DEVICE_CLASS(klass);
58331cf66eSThomas Huth     VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
59331cf66eSThomas Huth 
60331cf66eSThomas Huth     k->realize = virtio_ccw_blk_realize;
614f67d30bSMarc-André Lureau     device_class_set_props(dc, virtio_ccw_blk_properties);
62331cf66eSThomas Huth     set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
63331cf66eSThomas Huth }
64331cf66eSThomas Huth 
65331cf66eSThomas Huth static const TypeInfo virtio_ccw_blk = {
66331cf66eSThomas Huth     .name          = TYPE_VIRTIO_BLK_CCW,
67331cf66eSThomas Huth     .parent        = TYPE_VIRTIO_CCW_DEVICE,
68331cf66eSThomas Huth     .instance_size = sizeof(VirtIOBlkCcw),
69331cf66eSThomas Huth     .instance_init = virtio_ccw_blk_instance_init,
70331cf66eSThomas Huth     .class_init    = virtio_ccw_blk_class_init,
71331cf66eSThomas Huth };
72331cf66eSThomas Huth 
virtio_ccw_blk_register(void)73331cf66eSThomas Huth static void virtio_ccw_blk_register(void)
74331cf66eSThomas Huth {
75331cf66eSThomas Huth     type_register_static(&virtio_ccw_blk);
76331cf66eSThomas Huth }
77331cf66eSThomas Huth 
78331cf66eSThomas Huth type_init(virtio_ccw_blk_register)
79