2 * QEMU S390 virtio target
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/>.
21 #include "block/block.h"
22 #include "sysemu/sysemu.h"
23 #include "hw/boards.h"
24 #include "monitor/monitor.h"
25 #include "hw/loader.h"
27 #include "hw/virtio/virtio.h"
28 #include "hw/virtio/virtio-rng.h"
29 #include "hw/virtio/virtio-serial.h"
30 #include "hw/virtio/virtio-net.h"
31 #include "hw/virtio/vhost-scsi.h"
32 #include "hw/sysbus.h"
33 #include "sysemu/kvm.h"
35 #include "hw/s390x/s390-virtio-bus.h"
36 #include "hw/virtio/virtio-bus.h"
38 /* #define DEBUG_S390 */
41 #define DPRINTF(fmt, ...) \
42 do { fprintf(stderr, fmt, ## __VA_ARGS__); } while (0)
44 #define DPRINTF(fmt, ...) \
48 static void virtio_s390_bus_new(VirtioBusState
*bus
, size_t bus_size
,
49 VirtIOS390Device
*dev
);
51 static const TypeInfo s390_virtio_bus_info
= {
52 .name
= TYPE_S390_VIRTIO_BUS
,
54 .instance_size
= sizeof(VirtIOS390Bus
),
57 static ram_addr_t
s390_virtio_device_num_vq(VirtIOS390Device
*dev
);
59 /* length of VirtIO device pages */
60 const hwaddr virtio_size
= S390_DEVICE_PAGES
* TARGET_PAGE_SIZE
;
62 static void s390_virtio_bus_reset(void *opaque
)
64 VirtIOS390Bus
*bus
= opaque
;
65 bus
->next_ring
= bus
->dev_page
+ TARGET_PAGE_SIZE
;
68 void s390_virtio_reset_idx(VirtIOS390Device
*dev
)
74 num_vq
= s390_virtio_device_num_vq(dev
);
75 for (i
= 0; i
< num_vq
; i
++) {
76 idx_addr
= virtio_queue_get_avail_addr(dev
->vdev
, i
) +
77 VIRTIO_VRING_AVAIL_IDX_OFFS
;
78 stw_phys(&address_space_memory
, idx_addr
, 0);
79 idx_addr
= virtio_queue_get_used_addr(dev
->vdev
, i
) +
80 VIRTIO_VRING_USED_IDX_OFFS
;
81 stw_phys(&address_space_memory
, idx_addr
, 0);
85 VirtIOS390Bus
*s390_virtio_bus_init(ram_addr_t
*ram_size
)
91 /* Create bridge device */
92 dev
= qdev_create(NULL
, "s390-virtio-bridge");
93 qdev_init_nofail(dev
);
95 /* Create bus on bridge device */
97 _bus
= qbus_create(TYPE_S390_VIRTIO_BUS
, dev
, "s390-virtio");
98 bus
= DO_UPCAST(VirtIOS390Bus
, bus
, _bus
);
100 bus
->dev_page
= *ram_size
;
101 bus
->dev_offs
= bus
->dev_page
;
102 bus
->next_ring
= bus
->dev_page
+ TARGET_PAGE_SIZE
;
104 /* Enable hotplugging */
105 qbus_set_hotplug_handler(_bus
, dev
, &error_abort
);
107 /* Allocate RAM for VirtIO device pages (descriptors, queues, rings) */
108 *ram_size
+= S390_DEVICE_PAGES
* TARGET_PAGE_SIZE
;
110 qemu_register_reset(s390_virtio_bus_reset
, bus
);
114 static int s390_virtio_device_init(VirtIOS390Device
*dev
, VirtIODevice
*vdev
)
119 bus
= DO_UPCAST(VirtIOS390Bus
, bus
, dev
->qdev
.parent_bus
);
121 dev
->dev_offs
= bus
->dev_offs
;
122 dev
->feat_len
= sizeof(uint32_t); /* always keep 32 bits features */
124 dev_len
= VIRTIO_DEV_OFFS_CONFIG
;
125 dev_len
+= s390_virtio_device_num_vq(dev
) * VIRTIO_VQCONFIG_LEN
;
126 dev_len
+= dev
->feat_len
* 2;
127 dev_len
+= virtio_bus_get_vdev_config_len(&dev
->bus
);
129 bus
->dev_offs
+= dev_len
;
131 dev
->host_features
= virtio_bus_get_vdev_features(&dev
->bus
,
133 s390_virtio_device_sync(dev
);
134 s390_virtio_reset_idx(dev
);
135 if (dev
->qdev
.hotplugged
) {
136 s390_virtio_irq(VIRTIO_PARAM_DEV_ADD
, dev
->dev_offs
);
142 static int s390_virtio_net_init(VirtIOS390Device
*s390_dev
)
144 DeviceState
*qdev
= DEVICE(s390_dev
);
145 VirtIONetS390
*dev
= VIRTIO_NET_S390(s390_dev
);
146 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
148 virtio_net_set_config_size(&dev
->vdev
, s390_dev
->host_features
);
149 virtio_net_set_netclient_name(&dev
->vdev
, qdev
->id
,
150 object_get_typename(OBJECT(qdev
)));
151 qdev_set_parent_bus(vdev
, BUS(&s390_dev
->bus
));
152 if (qdev_init(vdev
) < 0) {
156 return s390_virtio_device_init(s390_dev
, VIRTIO_DEVICE(vdev
));
159 static void s390_virtio_net_instance_init(Object
*obj
)
161 VirtIONetS390
*dev
= VIRTIO_NET_S390(obj
);
163 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
167 static int s390_virtio_blk_init(VirtIOS390Device
*s390_dev
)
169 VirtIOBlkS390
*dev
= VIRTIO_BLK_S390(s390_dev
);
170 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
171 qdev_set_parent_bus(vdev
, BUS(&s390_dev
->bus
));
172 if (qdev_init(vdev
) < 0) {
175 return s390_virtio_device_init(s390_dev
, VIRTIO_DEVICE(vdev
));
178 static void s390_virtio_blk_instance_init(Object
*obj
)
180 VirtIOBlkS390
*dev
= VIRTIO_BLK_S390(obj
);
182 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
184 object_property_add_alias(obj
, "iothread", OBJECT(&dev
->vdev
),"iothread",
188 static int s390_virtio_serial_init(VirtIOS390Device
*s390_dev
)
190 VirtIOSerialS390
*dev
= VIRTIO_SERIAL_S390(s390_dev
);
191 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
192 DeviceState
*qdev
= DEVICE(s390_dev
);
197 bus
= DO_UPCAST(VirtIOS390Bus
, bus
, qdev
->parent_bus
);
200 * For command line compatibility, this sets the virtio-serial-device bus
204 bus_name
= g_strdup_printf("%s.0", qdev
->id
);
205 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev
), bus_name
);
209 qdev_set_parent_bus(vdev
, BUS(&s390_dev
->bus
));
210 if (qdev_init(vdev
) < 0) {
214 r
= s390_virtio_device_init(s390_dev
, VIRTIO_DEVICE(vdev
));
216 bus
->console
= s390_dev
;
222 static void s390_virtio_serial_instance_init(Object
*obj
)
224 VirtIOSerialS390
*dev
= VIRTIO_SERIAL_S390(obj
);
226 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
230 static int s390_virtio_scsi_init(VirtIOS390Device
*s390_dev
)
232 VirtIOSCSIS390
*dev
= VIRTIO_SCSI_S390(s390_dev
);
233 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
234 DeviceState
*qdev
= DEVICE(s390_dev
);
238 * For command line compatibility, this sets the virtio-scsi-device bus
242 bus_name
= g_strdup_printf("%s.0", qdev
->id
);
243 virtio_device_set_child_bus_name(VIRTIO_DEVICE(vdev
), bus_name
);
247 qdev_set_parent_bus(vdev
, BUS(&s390_dev
->bus
));
248 if (qdev_init(vdev
) < 0) {
252 return s390_virtio_device_init(s390_dev
, VIRTIO_DEVICE(vdev
));
255 static void s390_virtio_scsi_instance_init(Object
*obj
)
257 VirtIOSCSIS390
*dev
= VIRTIO_SCSI_S390(obj
);
259 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
263 #ifdef CONFIG_VHOST_SCSI
264 static int s390_vhost_scsi_init(VirtIOS390Device
*s390_dev
)
266 VHostSCSIS390
*dev
= VHOST_SCSI_S390(s390_dev
);
267 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
269 qdev_set_parent_bus(vdev
, BUS(&s390_dev
->bus
));
270 if (qdev_init(vdev
) < 0) {
274 return s390_virtio_device_init(s390_dev
, VIRTIO_DEVICE(vdev
));
277 static void s390_vhost_scsi_instance_init(Object
*obj
)
279 VHostSCSIS390
*dev
= VHOST_SCSI_S390(obj
);
281 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
287 static int s390_virtio_rng_init(VirtIOS390Device
*s390_dev
)
289 VirtIORNGS390
*dev
= VIRTIO_RNG_S390(s390_dev
);
290 DeviceState
*vdev
= DEVICE(&dev
->vdev
);
292 qdev_set_parent_bus(vdev
, BUS(&s390_dev
->bus
));
293 if (qdev_init(vdev
) < 0) {
297 object_property_set_link(OBJECT(dev
),
298 OBJECT(dev
->vdev
.conf
.rng
), "rng",
301 return s390_virtio_device_init(s390_dev
, VIRTIO_DEVICE(vdev
));
304 static void s390_virtio_rng_instance_init(Object
*obj
)
306 VirtIORNGS390
*dev
= VIRTIO_RNG_S390(obj
);
308 virtio_instance_init_common(obj
, &dev
->vdev
, sizeof(dev
->vdev
),
310 object_property_add_link(obj
, "rng", TYPE_RNG_BACKEND
,
311 (Object
**)&dev
->vdev
.conf
.rng
,
312 qdev_prop_allow_set_link_before_realize
,
313 OBJ_PROP_LINK_UNREF_ON_RELEASE
, NULL
);
316 static uint64_t s390_virtio_device_vq_token(VirtIOS390Device
*dev
, int vq
)
318 ram_addr_t token_off
;
320 token_off
= (dev
->dev_offs
+ VIRTIO_DEV_OFFS_CONFIG
) +
321 (vq
* VIRTIO_VQCONFIG_LEN
) +
322 VIRTIO_VQCONFIG_OFFS_TOKEN
;
324 return ldq_be_phys(&address_space_memory
, token_off
);
327 static ram_addr_t
s390_virtio_device_num_vq(VirtIOS390Device
*dev
)
329 VirtIODevice
*vdev
= dev
->vdev
;
332 for (num_vq
= 0; num_vq
< VIRTIO_PCI_QUEUE_MAX
; num_vq
++) {
333 if (!virtio_queue_get_num(vdev
, num_vq
)) {
341 static ram_addr_t
s390_virtio_next_ring(VirtIOS390Bus
*bus
)
343 ram_addr_t r
= bus
->next_ring
;
345 bus
->next_ring
+= VIRTIO_RING_LEN
;
349 void s390_virtio_device_sync(VirtIOS390Device
*dev
)
351 VirtIOS390Bus
*bus
= DO_UPCAST(VirtIOS390Bus
, bus
, dev
->qdev
.parent_bus
);
356 virtio_reset(dev
->vdev
);
359 stb_phys(&address_space_memory
,
360 dev
->dev_offs
+ VIRTIO_DEV_OFFS_TYPE
, dev
->vdev
->device_id
);
362 stb_phys(&address_space_memory
,
363 dev
->dev_offs
+ VIRTIO_DEV_OFFS_NUM_VQ
,
364 s390_virtio_device_num_vq(dev
));
365 stb_phys(&address_space_memory
,
366 dev
->dev_offs
+ VIRTIO_DEV_OFFS_FEATURE_LEN
, dev
->feat_len
);
368 stb_phys(&address_space_memory
,
369 dev
->dev_offs
+ VIRTIO_DEV_OFFS_CONFIG_LEN
, dev
->vdev
->config_len
);
371 num_vq
= s390_virtio_device_num_vq(dev
);
372 stb_phys(&address_space_memory
,
373 dev
->dev_offs
+ VIRTIO_DEV_OFFS_NUM_VQ
, num_vq
);
375 /* Sync virtqueues */
376 for (i
= 0; i
< num_vq
; i
++) {
377 ram_addr_t vq
= (dev
->dev_offs
+ VIRTIO_DEV_OFFS_CONFIG
) +
378 (i
* VIRTIO_VQCONFIG_LEN
);
381 vring
= s390_virtio_next_ring(bus
);
382 virtio_queue_set_addr(dev
->vdev
, i
, vring
);
383 virtio_queue_set_vector(dev
->vdev
, i
, i
);
384 stq_be_phys(&address_space_memory
,
385 vq
+ VIRTIO_VQCONFIG_OFFS_ADDRESS
, vring
);
386 stw_be_phys(&address_space_memory
,
387 vq
+ VIRTIO_VQCONFIG_OFFS_NUM
,
388 virtio_queue_get_num(dev
->vdev
, i
));
391 cur_offs
= dev
->dev_offs
;
392 cur_offs
+= VIRTIO_DEV_OFFS_CONFIG
;
393 cur_offs
+= num_vq
* VIRTIO_VQCONFIG_LEN
;
395 /* Sync feature bitmap */
396 stl_le_phys(&address_space_memory
, cur_offs
, dev
->host_features
);
398 dev
->feat_offs
= cur_offs
+ dev
->feat_len
;
399 cur_offs
+= dev
->feat_len
* 2;
401 /* Sync config space */
402 virtio_bus_get_vdev_config(&dev
->bus
, dev
->vdev
->config
);
404 cpu_physical_memory_write(cur_offs
,
405 dev
->vdev
->config
, dev
->vdev
->config_len
);
406 cur_offs
+= dev
->vdev
->config_len
;
409 void s390_virtio_device_update_status(VirtIOS390Device
*dev
)
411 VirtIODevice
*vdev
= dev
->vdev
;
414 virtio_set_status(vdev
, ldub_phys(&address_space_memory
,
415 dev
->dev_offs
+ VIRTIO_DEV_OFFS_STATUS
));
417 /* Update guest supported feature bitmap */
419 features
= bswap32(ldl_be_phys(&address_space_memory
, dev
->feat_offs
));
420 virtio_set_features(vdev
, features
);
423 VirtIOS390Device
*s390_virtio_bus_console(VirtIOS390Bus
*bus
)
428 /* Find a device by vring address */
429 VirtIOS390Device
*s390_virtio_bus_find_vring(VirtIOS390Bus
*bus
,
436 QTAILQ_FOREACH(kid
, &bus
->bus
.children
, sibling
) {
437 VirtIOS390Device
*dev
= (VirtIOS390Device
*)kid
->child
;
439 for(i
= 0; i
< VIRTIO_PCI_QUEUE_MAX
; i
++) {
440 if (!virtio_queue_get_addr(dev
->vdev
, i
))
442 if (virtio_queue_get_addr(dev
->vdev
, i
) == mem
) {
454 /* Find a device by device descriptor location */
455 VirtIOS390Device
*s390_virtio_bus_find_mem(VirtIOS390Bus
*bus
, ram_addr_t mem
)
459 QTAILQ_FOREACH(kid
, &bus
->bus
.children
, sibling
) {
460 VirtIOS390Device
*dev
= (VirtIOS390Device
*)kid
->child
;
461 if (dev
->dev_offs
== mem
) {
469 /* DeviceState to VirtIOS390Device. Note: used on datapath,
470 * be careful and test performance if you change this.
472 static inline VirtIOS390Device
*to_virtio_s390_device_fast(DeviceState
*d
)
474 return container_of(d
, VirtIOS390Device
, qdev
);
477 /* DeviceState to VirtIOS390Device. TODO: use QOM. */
478 static inline VirtIOS390Device
*to_virtio_s390_device(DeviceState
*d
)
480 return container_of(d
, VirtIOS390Device
, qdev
);
483 static void virtio_s390_notify(DeviceState
*d
, uint16_t vector
)
485 VirtIOS390Device
*dev
= to_virtio_s390_device_fast(d
);
486 uint64_t token
= s390_virtio_device_vq_token(dev
, vector
);
488 s390_virtio_irq(0, token
);
491 static unsigned virtio_s390_get_features(DeviceState
*d
)
493 VirtIOS390Device
*dev
= to_virtio_s390_device(d
);
494 return dev
->host_features
;
497 /**************** S390 Virtio Bus Device Descriptions *******************/
499 static Property s390_virtio_net_properties
[] = {
500 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device
, host_features
),
501 DEFINE_VIRTIO_NET_FEATURES(VirtIOS390Device
, host_features
),
502 DEFINE_PROP_END_OF_LIST(),
505 static void s390_virtio_net_class_init(ObjectClass
*klass
, void *data
)
507 DeviceClass
*dc
= DEVICE_CLASS(klass
);
508 VirtIOS390DeviceClass
*k
= VIRTIO_S390_DEVICE_CLASS(klass
);
510 k
->init
= s390_virtio_net_init
;
511 dc
->props
= s390_virtio_net_properties
;
514 static const TypeInfo s390_virtio_net
= {
515 .name
= TYPE_VIRTIO_NET_S390
,
516 .parent
= TYPE_VIRTIO_S390_DEVICE
,
517 .instance_size
= sizeof(VirtIONetS390
),
518 .instance_init
= s390_virtio_net_instance_init
,
519 .class_init
= s390_virtio_net_class_init
,
522 static void s390_virtio_blk_class_init(ObjectClass
*klass
, void *data
)
524 VirtIOS390DeviceClass
*k
= VIRTIO_S390_DEVICE_CLASS(klass
);
526 k
->init
= s390_virtio_blk_init
;
529 static const TypeInfo s390_virtio_blk
= {
530 .name
= "virtio-blk-s390",
531 .parent
= TYPE_VIRTIO_S390_DEVICE
,
532 .instance_size
= sizeof(VirtIOBlkS390
),
533 .instance_init
= s390_virtio_blk_instance_init
,
534 .class_init
= s390_virtio_blk_class_init
,
537 static Property s390_virtio_serial_properties
[] = {
538 DEFINE_PROP_END_OF_LIST(),
541 static void s390_virtio_serial_class_init(ObjectClass
*klass
, void *data
)
543 DeviceClass
*dc
= DEVICE_CLASS(klass
);
544 VirtIOS390DeviceClass
*k
= VIRTIO_S390_DEVICE_CLASS(klass
);
546 k
->init
= s390_virtio_serial_init
;
547 dc
->props
= s390_virtio_serial_properties
;
550 static const TypeInfo s390_virtio_serial
= {
551 .name
= TYPE_VIRTIO_SERIAL_S390
,
552 .parent
= TYPE_VIRTIO_S390_DEVICE
,
553 .instance_size
= sizeof(VirtIOSerialS390
),
554 .instance_init
= s390_virtio_serial_instance_init
,
555 .class_init
= s390_virtio_serial_class_init
,
558 static Property s390_virtio_rng_properties
[] = {
559 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device
, host_features
),
560 DEFINE_PROP_END_OF_LIST(),
563 static void s390_virtio_rng_class_init(ObjectClass
*klass
, void *data
)
565 DeviceClass
*dc
= DEVICE_CLASS(klass
);
566 VirtIOS390DeviceClass
*k
= VIRTIO_S390_DEVICE_CLASS(klass
);
568 k
->init
= s390_virtio_rng_init
;
569 dc
->props
= s390_virtio_rng_properties
;
572 static const TypeInfo s390_virtio_rng
= {
573 .name
= TYPE_VIRTIO_RNG_S390
,
574 .parent
= TYPE_VIRTIO_S390_DEVICE
,
575 .instance_size
= sizeof(VirtIORNGS390
),
576 .instance_init
= s390_virtio_rng_instance_init
,
577 .class_init
= s390_virtio_rng_class_init
,
580 static int s390_virtio_busdev_init(DeviceState
*dev
)
582 VirtIOS390Device
*_dev
= (VirtIOS390Device
*)dev
;
583 VirtIOS390DeviceClass
*_info
= VIRTIO_S390_DEVICE_GET_CLASS(dev
);
585 virtio_s390_bus_new(&_dev
->bus
, sizeof(_dev
->bus
), _dev
);
587 return _info
->init(_dev
);
590 static void s390_virtio_busdev_reset(DeviceState
*dev
)
592 VirtIOS390Device
*_dev
= (VirtIOS390Device
*)dev
;
594 virtio_reset(_dev
->vdev
);
597 static void virtio_s390_device_class_init(ObjectClass
*klass
, void *data
)
599 DeviceClass
*dc
= DEVICE_CLASS(klass
);
601 dc
->init
= s390_virtio_busdev_init
;
602 dc
->bus_type
= TYPE_S390_VIRTIO_BUS
;
603 dc
->reset
= s390_virtio_busdev_reset
;
606 static const TypeInfo virtio_s390_device_info
= {
607 .name
= TYPE_VIRTIO_S390_DEVICE
,
608 .parent
= TYPE_DEVICE
,
609 .instance_size
= sizeof(VirtIOS390Device
),
610 .class_init
= virtio_s390_device_class_init
,
611 .class_size
= sizeof(VirtIOS390DeviceClass
),
615 static Property s390_virtio_scsi_properties
[] = {
616 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device
, host_features
),
617 DEFINE_VIRTIO_SCSI_FEATURES(VirtIOS390Device
, host_features
),
618 DEFINE_PROP_END_OF_LIST(),
621 static void s390_virtio_scsi_class_init(ObjectClass
*klass
, void *data
)
623 DeviceClass
*dc
= DEVICE_CLASS(klass
);
624 VirtIOS390DeviceClass
*k
= VIRTIO_S390_DEVICE_CLASS(klass
);
626 k
->init
= s390_virtio_scsi_init
;
627 dc
->props
= s390_virtio_scsi_properties
;
630 static const TypeInfo s390_virtio_scsi
= {
631 .name
= TYPE_VIRTIO_SCSI_S390
,
632 .parent
= TYPE_VIRTIO_S390_DEVICE
,
633 .instance_size
= sizeof(VirtIOSCSIS390
),
634 .instance_init
= s390_virtio_scsi_instance_init
,
635 .class_init
= s390_virtio_scsi_class_init
,
638 #ifdef CONFIG_VHOST_SCSI
639 static Property s390_vhost_scsi_properties
[] = {
640 DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device
, host_features
),
641 DEFINE_PROP_END_OF_LIST(),
644 static void s390_vhost_scsi_class_init(ObjectClass
*klass
, void *data
)
646 DeviceClass
*dc
= DEVICE_CLASS(klass
);
647 VirtIOS390DeviceClass
*k
= VIRTIO_S390_DEVICE_CLASS(klass
);
649 k
->init
= s390_vhost_scsi_init
;
650 dc
->props
= s390_vhost_scsi_properties
;
653 static const TypeInfo s390_vhost_scsi
= {
654 .name
= TYPE_VHOST_SCSI_S390
,
655 .parent
= TYPE_VIRTIO_S390_DEVICE
,
656 .instance_size
= sizeof(VHostSCSIS390
),
657 .instance_init
= s390_vhost_scsi_instance_init
,
658 .class_init
= s390_vhost_scsi_class_init
,
662 /***************** S390 Virtio Bus Bridge Device *******************/
663 /* Only required to have the virtio bus as child in the system bus */
665 static int s390_virtio_bridge_init(SysBusDevice
*dev
)
671 static void s390_virtio_bridge_class_init(ObjectClass
*klass
, void *data
)
673 SysBusDeviceClass
*k
= SYS_BUS_DEVICE_CLASS(klass
);
675 k
->init
= s390_virtio_bridge_init
;
678 static const TypeInfo s390_virtio_bridge_info
= {
679 .name
= "s390-virtio-bridge",
680 .parent
= TYPE_SYS_BUS_DEVICE
,
681 .instance_size
= sizeof(SysBusDevice
),
682 .class_init
= s390_virtio_bridge_class_init
,
683 .interfaces
= (InterfaceInfo
[]) {
684 { TYPE_HOTPLUG_HANDLER
},
689 /* virtio-s390-bus */
691 static void virtio_s390_bus_new(VirtioBusState
*bus
, size_t bus_size
,
692 VirtIOS390Device
*dev
)
694 DeviceState
*qdev
= DEVICE(dev
);
695 char virtio_bus_name
[] = "virtio-bus";
697 qbus_create_inplace(bus
, bus_size
, TYPE_VIRTIO_S390_BUS
,
698 qdev
, virtio_bus_name
);
701 static void virtio_s390_bus_class_init(ObjectClass
*klass
, void *data
)
703 VirtioBusClass
*k
= VIRTIO_BUS_CLASS(klass
);
704 BusClass
*bus_class
= BUS_CLASS(klass
);
705 bus_class
->max_dev
= 1;
706 k
->notify
= virtio_s390_notify
;
707 k
->get_features
= virtio_s390_get_features
;
710 static const TypeInfo virtio_s390_bus_info
= {
711 .name
= TYPE_VIRTIO_S390_BUS
,
712 .parent
= TYPE_VIRTIO_BUS
,
713 .instance_size
= sizeof(VirtioS390BusState
),
714 .class_init
= virtio_s390_bus_class_init
,
717 static void s390_virtio_register_types(void)
719 type_register_static(&virtio_s390_bus_info
);
720 type_register_static(&s390_virtio_bus_info
);
721 type_register_static(&virtio_s390_device_info
);
722 type_register_static(&s390_virtio_serial
);
723 type_register_static(&s390_virtio_blk
);
724 type_register_static(&s390_virtio_net
);
725 type_register_static(&s390_virtio_scsi
);
726 #ifdef CONFIG_VHOST_SCSI
727 type_register_static(&s390_vhost_scsi
);
729 type_register_static(&s390_virtio_rng
);
730 type_register_static(&s390_virtio_bridge_info
);
733 type_init(s390_virtio_register_types
)