1 /* 2 * virtio ccw target definitions 3 * 4 * Copyright 2012 IBM Corp. 5 * Author(s): Cornelia Huck <cornelia.huck@de.ibm.com> 6 * 7 * This work is licensed under the terms of the GNU GPL, version 2 or (at 8 * your option) any later version. See the COPYING file in the top-level 9 * directory. 10 */ 11 12 #ifndef HW_S390X_VIRTIO_CCW_H 13 #define HW_S390X_VIRTIO_CCW_H 14 15 #include <hw/virtio/virtio-blk.h> 16 #include <hw/virtio/virtio-net.h> 17 #include <hw/virtio/virtio-serial.h> 18 #include <hw/virtio/virtio-scsi.h> 19 #include <hw/virtio/virtio-balloon.h> 20 #include <hw/virtio/virtio-rng.h> 21 #include <hw/virtio/virtio-bus.h> 22 23 #define VIRTUAL_CSSID 0xfe 24 25 #define VIRTIO_CCW_CU_TYPE 0x3832 26 #define VIRTIO_CCW_CHPID_TYPE 0x32 27 28 #define CCW_CMD_SET_VQ 0x13 29 #define CCW_CMD_VDEV_RESET 0x33 30 #define CCW_CMD_READ_FEAT 0x12 31 #define CCW_CMD_WRITE_FEAT 0x11 32 #define CCW_CMD_READ_CONF 0x22 33 #define CCW_CMD_WRITE_CONF 0x21 34 #define CCW_CMD_WRITE_STATUS 0x31 35 #define CCW_CMD_SET_IND 0x43 36 #define CCW_CMD_SET_CONF_IND 0x53 37 #define CCW_CMD_READ_VQ_CONF 0x32 38 39 #define TYPE_VIRTIO_CCW_DEVICE "virtio-ccw-device" 40 #define VIRTIO_CCW_DEVICE(obj) \ 41 OBJECT_CHECK(VirtioCcwDevice, (obj), TYPE_VIRTIO_CCW_DEVICE) 42 #define VIRTIO_CCW_DEVICE_CLASS(klass) \ 43 OBJECT_CLASS_CHECK(VirtIOCCWDeviceClass, (klass), TYPE_VIRTIO_CCW_DEVICE) 44 #define VIRTIO_CCW_DEVICE_GET_CLASS(obj) \ 45 OBJECT_GET_CLASS(VirtIOCCWDeviceClass, (obj), TYPE_VIRTIO_CCW_DEVICE) 46 47 typedef struct VirtioBusState VirtioCcwBusState; 48 typedef struct VirtioBusClass VirtioCcwBusClass; 49 50 #define TYPE_VIRTIO_CCW_BUS "virtio-ccw-bus" 51 #define VIRTIO_CCW_BUS(obj) \ 52 OBJECT_CHECK(VirtioCcwBus, (obj), TYPE_VIRTIO_CCW_BUS) 53 #define VIRTIO_CCW_BUS_GET_CLASS(obj) \ 54 OBJECT_CHECK(VirtioCcwBusState, (obj), TYPE_VIRTIO_CCW_BUS) 55 #define VIRTIO_CCW_BUS_CLASS(klass) \ 56 OBJECT_CLASS_CHECK(VirtioCcwBusClass, klass, TYPE_VIRTIO_CCW_BUS) 57 58 typedef struct VirtioCcwDevice VirtioCcwDevice; 59 60 void virtio_ccw_bus_new(VirtioBusState *bus, VirtioCcwDevice *dev); 61 62 typedef struct VirtIOCCWDeviceClass { 63 DeviceClass parent_class; 64 int (*init)(VirtioCcwDevice *dev); 65 int (*exit)(VirtioCcwDevice *dev); 66 } VirtIOCCWDeviceClass; 67 68 /* Change here if we want to support more feature bits. */ 69 #define VIRTIO_CCW_FEATURE_SIZE 1 70 71 struct VirtioCcwDevice { 72 DeviceState parent_obj; 73 SubchDev *sch; 74 VirtIODevice *vdev; 75 char *bus_id; 76 NICConf nic; 77 uint32_t host_features[VIRTIO_CCW_FEATURE_SIZE]; 78 virtio_serial_conf serial; 79 virtio_net_conf net; 80 VirtIORNGConf rng; 81 VirtioBusState bus; 82 /* Guest provided values: */ 83 hwaddr indicators; 84 hwaddr indicators2; 85 }; 86 87 /* virtual css bus type */ 88 typedef struct VirtualCssBus { 89 BusState parent_obj; 90 } VirtualCssBus; 91 92 #define TYPE_VIRTUAL_CSS_BUS "virtual-css-bus" 93 #define VIRTUAL_CSS_BUS(obj) \ 94 OBJECT_CHECK(VirtualCssBus, (obj), TYPE_VIRTUAL_CSS_BUS) 95 96 /* virtio-scsi-ccw */ 97 98 #define TYPE_VIRTIO_SCSI_CCW "virtio-scsi-ccw" 99 #define VIRTIO_SCSI_CCW(obj) \ 100 OBJECT_CHECK(VirtIOSCSICcw, (obj), TYPE_VIRTIO_SCSI_CCW) 101 102 typedef struct VirtIOSCSICcw { 103 VirtioCcwDevice parent_obj; 104 VirtIOSCSI vdev; 105 } VirtIOSCSICcw; 106 107 /* virtio-blk-ccw */ 108 109 #define TYPE_VIRTIO_BLK_CCW "virtio-blk-ccw" 110 #define VIRTIO_BLK_CCW(obj) \ 111 OBJECT_CHECK(VirtIOBlkCcw, (obj), TYPE_VIRTIO_BLK_CCW) 112 113 typedef struct VirtIOBlkCcw { 114 VirtioCcwDevice parent_obj; 115 VirtIOBlock vdev; 116 VirtIOBlkConf blk; 117 } VirtIOBlkCcw; 118 119 /* virtio-balloon-ccw */ 120 121 #define TYPE_VIRTIO_BALLOON_CCW "virtio-balloon-ccw" 122 #define VIRTIO_BALLOON_CCW(obj) \ 123 OBJECT_CHECK(VirtIOBalloonCcw, (obj), TYPE_VIRTIO_BALLOON_CCW) 124 125 typedef struct VirtIOBalloonCcw { 126 VirtioCcwDevice parent_obj; 127 VirtIOBalloon vdev; 128 } VirtIOBalloonCcw; 129 130 VirtualCssBus *virtual_css_bus_init(void); 131 void virtio_ccw_device_update_status(SubchDev *sch); 132 VirtIODevice *virtio_ccw_get_vdev(SubchDev *sch); 133 #endif 134