qdev: skip bus check for bus-less devices in qdev_unplug()
[qemu.git] / hw / s390x / s390-virtio-bus.h
blobac81bd89eee52cdae2d31910d8ddb8b1f43ac3e8
1 /*
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
22 #include "hw/virtio/virtio-blk.h"
23 #include "hw/virtio/virtio-net.h"
24 #include "hw/virtio/virtio-rng.h"
25 #include "hw/virtio/virtio-serial.h"
26 #include "hw/virtio/virtio-scsi.h"
27 #include "hw/virtio/virtio-bus.h"
28 #ifdef CONFIG_VHOST_SCSI
29 #include "hw/virtio/vhost-scsi.h"
30 #endif
32 #define VIRTIO_DEV_OFFS_TYPE 0 /* 8 bits */
33 #define VIRTIO_DEV_OFFS_NUM_VQ 1 /* 8 bits */
34 #define VIRTIO_DEV_OFFS_FEATURE_LEN 2 /* 8 bits */
35 #define VIRTIO_DEV_OFFS_CONFIG_LEN 3 /* 8 bits */
36 #define VIRTIO_DEV_OFFS_STATUS 4 /* 8 bits */
37 #define VIRTIO_DEV_OFFS_CONFIG 5 /* dynamic */
39 #define VIRTIO_VQCONFIG_OFFS_TOKEN 0 /* 64 bits */
40 #define VIRTIO_VQCONFIG_OFFS_ADDRESS 8 /* 64 bits */
41 #define VIRTIO_VQCONFIG_OFFS_NUM 16 /* 16 bits */
42 #define VIRTIO_VQCONFIG_LEN 24
44 #define VIRTIO_RING_LEN (TARGET_PAGE_SIZE * 3)
45 #define VIRTIO_VRING_AVAIL_IDX_OFFS 2
46 #define VIRTIO_VRING_USED_IDX_OFFS 2
47 #define S390_DEVICE_PAGES 512
49 #define VIRTIO_PARAM_MASK 0xff
50 #define VIRTIO_PARAM_VRING_INTERRUPT 0x0
51 #define VIRTIO_PARAM_CONFIG_CHANGED 0x1
52 #define VIRTIO_PARAM_DEV_ADD 0x2
54 #define TYPE_VIRTIO_S390_DEVICE "virtio-s390-device"
55 #define VIRTIO_S390_DEVICE(obj) \
56 OBJECT_CHECK(VirtIOS390Device, (obj), TYPE_VIRTIO_S390_DEVICE)
57 #define VIRTIO_S390_DEVICE_CLASS(klass) \
58 OBJECT_CLASS_CHECK(VirtIOS390DeviceClass, (klass), TYPE_VIRTIO_S390_DEVICE)
59 #define VIRTIO_S390_DEVICE_GET_CLASS(obj) \
60 OBJECT_GET_CLASS(VirtIOS390DeviceClass, (obj), TYPE_VIRTIO_S390_DEVICE)
62 #define TYPE_S390_VIRTIO_BUS "s390-virtio-bus"
63 #define S390_VIRTIO_BUS(obj) \
64 OBJECT_CHECK(VirtIOS390Bus, (obj), TYPE_S390_VIRTIO_BUS)
66 /* virtio-s390-bus */
68 typedef struct VirtioBusState VirtioS390BusState;
69 typedef struct VirtioBusClass VirtioS390BusClass;
71 #define TYPE_VIRTIO_S390_BUS "virtio-s390-bus"
72 #define VIRTIO_S390_BUS(obj) \
73 OBJECT_CHECK(VirtioS390BusState, (obj), TYPE_VIRTIO_S390_BUS)
74 #define VIRTIO_S390_BUS_GET_CLASS(obj) \
75 OBJECT_GET_CLASS(VirtioS390BusClass, obj, TYPE_VIRTIO_S390_BUS)
76 #define VIRTIO_S390_BUS_CLASS(klass) \
77 OBJECT_CLASS_CHECK(VirtioS390BusClass, klass, TYPE_VIRTIO_S390_BUS)
80 typedef struct VirtIOS390Device VirtIOS390Device;
82 typedef struct VirtIOS390DeviceClass {
83 DeviceClass qdev;
84 int (*init)(VirtIOS390Device *dev);
85 } VirtIOS390DeviceClass;
87 struct VirtIOS390Device {
88 DeviceState qdev;
89 ram_addr_t dev_offs;
90 ram_addr_t feat_offs;
91 uint8_t feat_len;
92 VirtIODevice *vdev;
93 uint32_t host_features;
94 VirtioBusState bus;
97 typedef struct VirtIOS390Bus {
98 BusState bus;
100 VirtIOS390Device *console;
101 ram_addr_t dev_page;
102 ram_addr_t dev_offs;
103 ram_addr_t next_ring;
104 } VirtIOS390Bus;
107 void s390_virtio_device_update_status(VirtIOS390Device *dev);
109 VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus);
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;
126 VirtIOBlock vdev;
127 VirtIOBlkConf blk;
128 } VirtIOBlkS390;
130 /* virtio-scsi-s390 */
132 #define TYPE_VIRTIO_SCSI_S390 "virtio-scsi-s390"
133 #define VIRTIO_SCSI_S390(obj) \
134 OBJECT_CHECK(VirtIOSCSIS390, (obj), TYPE_VIRTIO_SCSI_S390)
136 typedef struct VirtIOSCSIS390 {
137 VirtIOS390Device parent_obj;
138 VirtIOSCSI vdev;
139 } VirtIOSCSIS390;
141 /* virtio-serial-s390 */
143 #define TYPE_VIRTIO_SERIAL_S390 "virtio-serial-s390"
144 #define VIRTIO_SERIAL_S390(obj) \
145 OBJECT_CHECK(VirtIOSerialS390, (obj), TYPE_VIRTIO_SERIAL_S390)
147 typedef struct VirtIOSerialS390 {
148 VirtIOS390Device parent_obj;
149 VirtIOSerial vdev;
150 } VirtIOSerialS390;
152 /* virtio-net-s390 */
154 #define TYPE_VIRTIO_NET_S390 "virtio-net-s390"
155 #define VIRTIO_NET_S390(obj) \
156 OBJECT_CHECK(VirtIONetS390, (obj), TYPE_VIRTIO_NET_S390)
158 typedef struct VirtIONetS390 {
159 VirtIOS390Device parent_obj;
160 VirtIONet vdev;
161 } VirtIONetS390;
163 /* vhost-scsi-s390 */
165 #ifdef CONFIG_VHOST_SCSI
166 #define TYPE_VHOST_SCSI_S390 "vhost-scsi-s390"
167 #define VHOST_SCSI_S390(obj) \
168 OBJECT_CHECK(VHostSCSIS390, (obj), TYPE_VHOST_SCSI_S390)
170 typedef struct VHostSCSIS390 {
171 VirtIOS390Device parent_obj;
172 VHostSCSI vdev;
173 } VHostSCSIS390;
174 #endif
176 /* virtio-rng-s390 */
178 #define TYPE_VIRTIO_RNG_S390 "virtio-rng-s390"
179 #define VIRTIO_RNG_S390(obj) \
180 OBJECT_CHECK(VirtIORNGS390, (obj), TYPE_VIRTIO_RNG_S390)
182 typedef struct VirtIORNGS390 {
183 VirtIOS390Device parent_obj;
184 VirtIORNG vdev;
185 } VirtIORNGS390;
187 #endif