2 * QEMU S390x VirtIO BUS definitions
4 * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
19 #ifndef HW_S390_VIRTIO_BUS_H
20 #define HW_S390_VIRTIO_BUS_H 1
24 #include "standard-headers/asm-s390/kvm_virtio.h"
25 #include "standard-headers/linux/virtio_ring.h"
26 #include "hw/virtio/virtio-blk.h"
27 #include "hw/virtio/virtio-net.h"
28 #include "hw/virtio/virtio-rng.h"
29 #include "hw/virtio/virtio-serial.h"
30 #include "hw/virtio/virtio-scsi.h"
31 #include "hw/virtio/virtio-bus.h"
32 #ifdef CONFIG_VHOST_SCSI
33 #include "hw/virtio/vhost-scsi.h"
36 typedef struct kvm_device_desc KvmDeviceDesc
;
38 #define VIRTIO_DEV_OFFS_TYPE offsetof(KvmDeviceDesc, type)
39 #define VIRTIO_DEV_OFFS_NUM_VQ offsetof(KvmDeviceDesc, num_vq)
40 #define VIRTIO_DEV_OFFS_FEATURE_LEN offsetof(KvmDeviceDesc, feature_len)
41 #define VIRTIO_DEV_OFFS_CONFIG_LEN offsetof(KvmDeviceDesc, config_len)
42 #define VIRTIO_DEV_OFFS_STATUS offsetof(KvmDeviceDesc, status)
43 #define VIRTIO_DEV_OFFS_CONFIG offsetof(KvmDeviceDesc, config)
45 typedef struct kvm_vqconfig KvmVqConfig
;
46 #define VIRTIO_VQCONFIG_OFFS_TOKEN offsetof(KvmVqConfig,token) /* 64 bit */
47 #define VIRTIO_VQCONFIG_OFFS_ADDRESS offsetof(KvmVqConfig, address) /* 64 bit */
48 #define VIRTIO_VQCONFIG_OFFS_NUM offsetof(KvmVqConfig, num) /* 16 bit */
49 #define VIRTIO_VQCONFIG_LEN sizeof(KvmVqConfig)
51 #define VIRTIO_RING_LEN (TARGET_PAGE_SIZE * 3)
52 #define VIRTIO_VRING_AVAIL_IDX_OFFS offsetof(struct vring_avail, idx)
53 #define VIRTIO_VRING_USED_IDX_OFFS offsetof(struct vring_used, idx)
54 #define S390_DEVICE_PAGES 512
56 #define TYPE_VIRTIO_S390_DEVICE "virtio-s390-device"
57 #define VIRTIO_S390_DEVICE(obj) \
58 OBJECT_CHECK(VirtIOS390Device, (obj), TYPE_VIRTIO_S390_DEVICE)
59 #define VIRTIO_S390_DEVICE_CLASS(klass) \
60 OBJECT_CLASS_CHECK(VirtIOS390DeviceClass, (klass), TYPE_VIRTIO_S390_DEVICE)
61 #define VIRTIO_S390_DEVICE_GET_CLASS(obj) \
62 OBJECT_GET_CLASS(VirtIOS390DeviceClass, (obj), TYPE_VIRTIO_S390_DEVICE)
64 #define TYPE_S390_VIRTIO_BUS "s390-virtio-bus"
65 #define S390_VIRTIO_BUS(obj) \
66 OBJECT_CHECK(VirtIOS390Bus, (obj), TYPE_S390_VIRTIO_BUS)
70 typedef struct VirtioBusState VirtioS390BusState
;
71 typedef struct VirtioBusClass VirtioS390BusClass
;
73 #define TYPE_VIRTIO_S390_BUS "virtio-s390-bus"
74 #define VIRTIO_S390_BUS(obj) \
75 OBJECT_CHECK(VirtioS390BusState, (obj), TYPE_VIRTIO_S390_BUS)
76 #define VIRTIO_S390_BUS_GET_CLASS(obj) \
77 OBJECT_GET_CLASS(VirtioS390BusClass, obj, TYPE_VIRTIO_S390_BUS)
78 #define VIRTIO_S390_BUS_CLASS(klass) \
79 OBJECT_CLASS_CHECK(VirtioS390BusClass, klass, TYPE_VIRTIO_S390_BUS)
82 typedef struct VirtIOS390Device VirtIOS390Device
;
84 typedef struct VirtIOS390DeviceClass
{
86 void (*realize
)(VirtIOS390Device
*dev
, Error
**errp
);
87 } VirtIOS390DeviceClass
;
89 struct VirtIOS390Device
{
98 typedef struct VirtIOS390Bus
{
101 VirtIOS390Device
*console
;
104 ram_addr_t next_ring
;
108 void s390_virtio_device_update_status(VirtIOS390Device
*dev
);
110 VirtIOS390Bus
*s390_virtio_bus_init(ram_addr_t
*ram_size
);
112 VirtIOS390Device
*s390_virtio_bus_find_vring(VirtIOS390Bus
*bus
,
113 ram_addr_t mem
, int *vq_num
);
114 VirtIOS390Device
*s390_virtio_bus_find_mem(VirtIOS390Bus
*bus
, ram_addr_t mem
);
115 void s390_virtio_device_sync(VirtIOS390Device
*dev
);
116 void s390_virtio_reset_idx(VirtIOS390Device
*dev
);
118 /* virtio-blk-s390 */
120 #define TYPE_VIRTIO_BLK_S390 "virtio-blk-s390"
121 #define VIRTIO_BLK_S390(obj) \
122 OBJECT_CHECK(VirtIOBlkS390, (obj), TYPE_VIRTIO_BLK_S390)
124 typedef struct VirtIOBlkS390
{
125 VirtIOS390Device parent_obj
;
129 /* virtio-scsi-s390 */
131 #define TYPE_VIRTIO_SCSI_S390 "virtio-scsi-s390"
132 #define VIRTIO_SCSI_S390(obj) \
133 OBJECT_CHECK(VirtIOSCSIS390, (obj), TYPE_VIRTIO_SCSI_S390)
135 typedef struct VirtIOSCSIS390
{
136 VirtIOS390Device parent_obj
;
140 /* virtio-serial-s390 */
142 #define TYPE_VIRTIO_SERIAL_S390 "virtio-serial-s390"
143 #define VIRTIO_SERIAL_S390(obj) \
144 OBJECT_CHECK(VirtIOSerialS390, (obj), TYPE_VIRTIO_SERIAL_S390)
146 typedef struct VirtIOSerialS390
{
147 VirtIOS390Device parent_obj
;
151 /* virtio-net-s390 */
153 #define TYPE_VIRTIO_NET_S390 "virtio-net-s390"
154 #define VIRTIO_NET_S390(obj) \
155 OBJECT_CHECK(VirtIONetS390, (obj), TYPE_VIRTIO_NET_S390)
157 typedef struct VirtIONetS390
{
158 VirtIOS390Device parent_obj
;
162 /* vhost-scsi-s390 */
164 #ifdef CONFIG_VHOST_SCSI
165 #define TYPE_VHOST_SCSI_S390 "vhost-scsi-s390"
166 #define VHOST_SCSI_S390(obj) \
167 OBJECT_CHECK(VHostSCSIS390, (obj), TYPE_VHOST_SCSI_S390)
169 typedef struct VHostSCSIS390
{
170 VirtIOS390Device parent_obj
;
175 /* virtio-rng-s390 */
177 #define TYPE_VIRTIO_RNG_S390 "virtio-rng-s390"
178 #define VIRTIO_RNG_S390(obj) \
179 OBJECT_CHECK(VirtIORNGS390, (obj), TYPE_VIRTIO_RNG_S390)
181 typedef struct VirtIORNGS390
{
182 VirtIOS390Device parent_obj
;