156541db4SThomas Huth /*
256541db4SThomas Huth * virtio ccw 9p implementation
356541db4SThomas Huth *
456541db4SThomas Huth * Copyright 2012, 2015 IBM Corp.
556541db4SThomas Huth * Author(s): Pierre Morel <pmorel@linux.vnet.ibm.com>
656541db4SThomas Huth *
756541db4SThomas Huth * This work is licensed under the terms of the GNU GPL, version 2 or (at
856541db4SThomas Huth * your option) any later version. See the COPYING file in the top-level
956541db4SThomas Huth * directory.
1056541db4SThomas Huth */
1156541db4SThomas Huth
1256541db4SThomas Huth #include "qemu/osdep.h"
13a27bd6c7SMarkus Armbruster #include "hw/qdev-properties.h"
1456541db4SThomas Huth #include "hw/virtio/virtio.h"
1556541db4SThomas Huth #include "qapi/error.h"
160b8fa32fSMarkus Armbruster #include "qemu/module.h"
1756541db4SThomas Huth #include "virtio-ccw.h"
18*7da50d64SPaolo Bonzini #include "hw/9pfs/virtio-9p.h"
19*7da50d64SPaolo Bonzini
20*7da50d64SPaolo Bonzini #define TYPE_VIRTIO_9P_CCW "virtio-9p-ccw"
21*7da50d64SPaolo Bonzini OBJECT_DECLARE_SIMPLE_TYPE(V9fsCCWState, VIRTIO_9P_CCW)
22*7da50d64SPaolo Bonzini
23*7da50d64SPaolo Bonzini struct V9fsCCWState {
24*7da50d64SPaolo Bonzini VirtioCcwDevice parent_obj;
25*7da50d64SPaolo Bonzini V9fsVirtioState vdev;
26*7da50d64SPaolo Bonzini };
2756541db4SThomas Huth
virtio_ccw_9p_realize(VirtioCcwDevice * ccw_dev,Error ** errp)2856541db4SThomas Huth static void virtio_ccw_9p_realize(VirtioCcwDevice *ccw_dev, Error **errp)
2956541db4SThomas Huth {
3056541db4SThomas Huth V9fsCCWState *dev = VIRTIO_9P_CCW(ccw_dev);
3156541db4SThomas Huth DeviceState *vdev = DEVICE(&dev->vdev);
3256541db4SThomas Huth
3399ba777eSMarkus Armbruster qdev_realize(vdev, BUS(&ccw_dev->bus), errp);
3456541db4SThomas Huth }
3556541db4SThomas Huth
virtio_ccw_9p_instance_init(Object * obj)3656541db4SThomas Huth static void virtio_ccw_9p_instance_init(Object *obj)
3756541db4SThomas Huth {
3856541db4SThomas Huth V9fsCCWState *dev = VIRTIO_9P_CCW(obj);
3956541db4SThomas Huth
4056541db4SThomas Huth virtio_instance_init_common(obj, &dev->vdev, sizeof(dev->vdev),
4156541db4SThomas Huth TYPE_VIRTIO_9P);
4256541db4SThomas Huth }
4356541db4SThomas Huth
4456541db4SThomas Huth static Property virtio_ccw_9p_properties[] = {
4556541db4SThomas Huth DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
4656541db4SThomas Huth VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
4756541db4SThomas Huth DEFINE_PROP_UINT32("max_revision", VirtioCcwDevice, max_rev,
4856541db4SThomas Huth VIRTIO_CCW_MAX_REV),
4956541db4SThomas Huth DEFINE_PROP_END_OF_LIST(),
5056541db4SThomas Huth };
5156541db4SThomas Huth
virtio_ccw_9p_class_init(ObjectClass * klass,void * data)5256541db4SThomas Huth static void virtio_ccw_9p_class_init(ObjectClass *klass, void *data)
5356541db4SThomas Huth {
5456541db4SThomas Huth DeviceClass *dc = DEVICE_CLASS(klass);
5556541db4SThomas Huth VirtIOCCWDeviceClass *k = VIRTIO_CCW_DEVICE_CLASS(klass);
5656541db4SThomas Huth
5756541db4SThomas Huth k->realize = virtio_ccw_9p_realize;
584f67d30bSMarc-André Lureau device_class_set_props(dc, virtio_ccw_9p_properties);
5956541db4SThomas Huth set_bit(DEVICE_CATEGORY_STORAGE, dc->categories);
6056541db4SThomas Huth }
6156541db4SThomas Huth
6256541db4SThomas Huth static const TypeInfo virtio_ccw_9p_info = {
6356541db4SThomas Huth .name = TYPE_VIRTIO_9P_CCW,
6456541db4SThomas Huth .parent = TYPE_VIRTIO_CCW_DEVICE,
6556541db4SThomas Huth .instance_size = sizeof(V9fsCCWState),
6656541db4SThomas Huth .instance_init = virtio_ccw_9p_instance_init,
6756541db4SThomas Huth .class_init = virtio_ccw_9p_class_init,
6856541db4SThomas Huth };
6956541db4SThomas Huth
virtio_ccw_9p_register(void)7056541db4SThomas Huth static void virtio_ccw_9p_register(void)
7156541db4SThomas Huth {
7256541db4SThomas Huth type_register_static(&virtio_ccw_9p_info);
7356541db4SThomas Huth }
7456541db4SThomas Huth
7556541db4SThomas Huth type_init(virtio_ccw_9p_register)
76