]> Git Repo - qemu.git/blob - hw/s390x/s390-virtio-bus.h
virtio-s390: Convert to realize()
[qemu.git] / hw / s390x / s390-virtio-bus.h
1 /*
2  * QEMU S390x VirtIO BUS definitions
3  *
4  * Copyright (c) 2009 Alexander Graf <[email protected]>
5  *
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.
10  *
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.
15  *
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/>.
18  */
19 #ifndef HW_S390_VIRTIO_BUS_H
20 #define HW_S390_VIRTIO_BUS_H 1
21
22 #include <stddef.h>
23
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"
34 #endif
35
36 typedef struct kvm_device_desc KvmDeviceDesc;
37
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)
44
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)
50
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
55
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)
63
64 #define TYPE_S390_VIRTIO_BUS "s390-virtio-bus"
65 #define S390_VIRTIO_BUS(obj) \
66      OBJECT_CHECK(VirtIOS390Bus, (obj), TYPE_S390_VIRTIO_BUS)
67
68 /* virtio-s390-bus */
69
70 typedef struct VirtioBusState VirtioS390BusState;
71 typedef struct VirtioBusClass VirtioS390BusClass;
72
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)
80
81
82 typedef struct VirtIOS390Device VirtIOS390Device;
83
84 typedef struct VirtIOS390DeviceClass {
85     DeviceClass qdev;
86     void (*realize)(VirtIOS390Device *dev, Error **errp);
87 } VirtIOS390DeviceClass;
88
89 struct VirtIOS390Device {
90     DeviceState qdev;
91     ram_addr_t dev_offs;
92     ram_addr_t feat_offs;
93     uint8_t feat_len;
94     VirtIODevice *vdev;
95     uint32_t host_features;
96     VirtioBusState bus;
97 };
98
99 typedef struct VirtIOS390Bus {
100     BusState bus;
101
102     VirtIOS390Device *console;
103     ram_addr_t dev_page;
104     ram_addr_t dev_offs;
105     ram_addr_t next_ring;
106 } VirtIOS390Bus;
107
108
109 void s390_virtio_device_update_status(VirtIOS390Device *dev);
110
111 VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus);
112 VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size);
113
114 VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus,
115                                              ram_addr_t mem, int *vq_num);
116 VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem);
117 void s390_virtio_device_sync(VirtIOS390Device *dev);
118 void s390_virtio_reset_idx(VirtIOS390Device *dev);
119
120 /* virtio-blk-s390 */
121
122 #define TYPE_VIRTIO_BLK_S390 "virtio-blk-s390"
123 #define VIRTIO_BLK_S390(obj) \
124         OBJECT_CHECK(VirtIOBlkS390, (obj), TYPE_VIRTIO_BLK_S390)
125
126 typedef struct VirtIOBlkS390 {
127     VirtIOS390Device parent_obj;
128     VirtIOBlock vdev;
129 } VirtIOBlkS390;
130
131 /* virtio-scsi-s390 */
132
133 #define TYPE_VIRTIO_SCSI_S390 "virtio-scsi-s390"
134 #define VIRTIO_SCSI_S390(obj) \
135         OBJECT_CHECK(VirtIOSCSIS390, (obj), TYPE_VIRTIO_SCSI_S390)
136
137 typedef struct VirtIOSCSIS390 {
138     VirtIOS390Device parent_obj;
139     VirtIOSCSI vdev;
140 } VirtIOSCSIS390;
141
142 /* virtio-serial-s390 */
143
144 #define TYPE_VIRTIO_SERIAL_S390 "virtio-serial-s390"
145 #define VIRTIO_SERIAL_S390(obj) \
146         OBJECT_CHECK(VirtIOSerialS390, (obj), TYPE_VIRTIO_SERIAL_S390)
147
148 typedef struct VirtIOSerialS390 {
149     VirtIOS390Device parent_obj;
150     VirtIOSerial vdev;
151 } VirtIOSerialS390;
152
153 /* virtio-net-s390 */
154
155 #define TYPE_VIRTIO_NET_S390 "virtio-net-s390"
156 #define VIRTIO_NET_S390(obj) \
157         OBJECT_CHECK(VirtIONetS390, (obj), TYPE_VIRTIO_NET_S390)
158
159 typedef struct VirtIONetS390 {
160     VirtIOS390Device parent_obj;
161     VirtIONet vdev;
162 } VirtIONetS390;
163
164 /* vhost-scsi-s390 */
165
166 #ifdef CONFIG_VHOST_SCSI
167 #define TYPE_VHOST_SCSI_S390 "vhost-scsi-s390"
168 #define VHOST_SCSI_S390(obj) \
169         OBJECT_CHECK(VHostSCSIS390, (obj), TYPE_VHOST_SCSI_S390)
170
171 typedef struct VHostSCSIS390 {
172     VirtIOS390Device parent_obj;
173     VHostSCSI vdev;
174 } VHostSCSIS390;
175 #endif
176
177 /* virtio-rng-s390 */
178
179 #define TYPE_VIRTIO_RNG_S390 "virtio-rng-s390"
180 #define VIRTIO_RNG_S390(obj) \
181         OBJECT_CHECK(VirtIORNGS390, (obj), TYPE_VIRTIO_RNG_S390)
182
183 typedef struct VirtIORNGS390 {
184     VirtIOS390Device parent_obj;
185     VirtIORNG vdev;
186 } VirtIORNGS390;
187
188 #endif
This page took 0.03414 seconds and 4 git commands to generate.