Statistics
| Branch: | Revision:

root / hw / s390x / s390-virtio-bus.h @ 5d6c0c49

History | View | Annotate | Download (5.6 kB)

1 f3304eea Alexander Graf
/*
2 f3304eea Alexander Graf
 * QEMU S390x VirtIO BUS definitions
3 f3304eea Alexander Graf
 *
4 f3304eea Alexander Graf
 * Copyright (c) 2009 Alexander Graf <agraf@suse.de>
5 f3304eea Alexander Graf
 *
6 f3304eea Alexander Graf
 * This library is free software; you can redistribute it and/or
7 f3304eea Alexander Graf
 * modify it under the terms of the GNU Lesser General Public
8 f3304eea Alexander Graf
 * License as published by the Free Software Foundation; either
9 f3304eea Alexander Graf
 * version 2 of the License, or (at your option) any later version.
10 f3304eea Alexander Graf
 *
11 f3304eea Alexander Graf
 * This library is distributed in the hope that it will be useful,
12 f3304eea Alexander Graf
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 f3304eea Alexander Graf
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14 f3304eea Alexander Graf
 * Lesser General Public License for more details.
15 f3304eea Alexander Graf
 *
16 f3304eea Alexander Graf
 * You should have received a copy of the GNU Lesser General Public
17 f3304eea Alexander Graf
 * License along with this library; if not, see <http://www.gnu.org/licenses/>.
18 f3304eea Alexander Graf
 */
19 cb9c377f Paolo Bonzini
#ifndef HW_S390_VIRTIO_BUS_H
20 cb9c377f Paolo Bonzini
#define HW_S390_VIRTIO_BUS_H 1
21 f3304eea Alexander Graf
22 0d09e41a Paolo Bonzini
#include "hw/virtio/virtio-blk.h"
23 0d09e41a Paolo Bonzini
#include "hw/virtio/virtio-net.h"
24 0d09e41a Paolo Bonzini
#include "hw/virtio/virtio-rng.h"
25 0d09e41a Paolo Bonzini
#include "hw/virtio/virtio-serial.h"
26 0d09e41a Paolo Bonzini
#include "hw/virtio/virtio-scsi.h"
27 0d09e41a Paolo Bonzini
#include "hw/virtio/virtio-bus.h"
28 d6e51919 Paolo Bonzini
#ifdef CONFIG_VHOST_SCSI
29 d6e51919 Paolo Bonzini
#include "hw/virtio/vhost-scsi.h"
30 d6e51919 Paolo Bonzini
#endif
31 6c33286a Alexander Graf
32 f3304eea Alexander Graf
#define VIRTIO_DEV_OFFS_TYPE                0        /* 8 bits */
33 f3304eea Alexander Graf
#define VIRTIO_DEV_OFFS_NUM_VQ                1        /* 8 bits */
34 f3304eea Alexander Graf
#define VIRTIO_DEV_OFFS_FEATURE_LEN        2        /* 8 bits */
35 f3304eea Alexander Graf
#define VIRTIO_DEV_OFFS_CONFIG_LEN        3        /* 8 bits */
36 f3304eea Alexander Graf
#define VIRTIO_DEV_OFFS_STATUS                4        /* 8 bits */
37 f3304eea Alexander Graf
#define VIRTIO_DEV_OFFS_CONFIG                5        /* dynamic */
38 f3304eea Alexander Graf
39 f3304eea Alexander Graf
#define VIRTIO_VQCONFIG_OFFS_TOKEN        0        /* 64 bits */
40 f3304eea Alexander Graf
#define VIRTIO_VQCONFIG_OFFS_ADDRESS        8        /* 64 bits */
41 f3304eea Alexander Graf
#define VIRTIO_VQCONFIG_OFFS_NUM        16        /* 16 bits */
42 f3304eea Alexander Graf
#define VIRTIO_VQCONFIG_LEN                24
43 f3304eea Alexander Graf
44 f3304eea Alexander Graf
#define VIRTIO_RING_LEN                        (TARGET_PAGE_SIZE * 3)
45 4170aea1 Jens Freimann
#define VIRTIO_VRING_AVAIL_IDX_OFFS 2
46 4170aea1 Jens Freimann
#define VIRTIO_VRING_USED_IDX_OFFS 2
47 d1ff903c Alexander Graf
#define S390_DEVICE_PAGES                512
48 f3304eea Alexander Graf
49 7fa41e53 Alexander Graf
#define VIRTIO_PARAM_MASK               0xff
50 7fa41e53 Alexander Graf
#define VIRTIO_PARAM_VRING_INTERRUPT    0x0
51 7fa41e53 Alexander Graf
#define VIRTIO_PARAM_CONFIG_CHANGED     0x1
52 7fa41e53 Alexander Graf
#define VIRTIO_PARAM_DEV_ADD            0x2
53 7fa41e53 Alexander Graf
54 39bffca2 Anthony Liguori
#define TYPE_VIRTIO_S390_DEVICE "virtio-s390-device"
55 39bffca2 Anthony Liguori
#define VIRTIO_S390_DEVICE(obj) \
56 39bffca2 Anthony Liguori
     OBJECT_CHECK(VirtIOS390Device, (obj), TYPE_VIRTIO_S390_DEVICE)
57 39bffca2 Anthony Liguori
#define VIRTIO_S390_DEVICE_CLASS(klass) \
58 39bffca2 Anthony Liguori
     OBJECT_CLASS_CHECK(VirtIOS390DeviceClass, (klass), TYPE_VIRTIO_S390_DEVICE)
59 39bffca2 Anthony Liguori
#define VIRTIO_S390_DEVICE_GET_CLASS(obj) \
60 39bffca2 Anthony Liguori
     OBJECT_GET_CLASS(VirtIOS390DeviceClass, (obj), TYPE_VIRTIO_S390_DEVICE)
61 39bffca2 Anthony Liguori
62 0d936928 Anthony Liguori
#define TYPE_S390_VIRTIO_BUS "s390-virtio-bus"
63 0d936928 Anthony Liguori
#define S390_VIRTIO_BUS(obj) \
64 0d936928 Anthony Liguori
     OBJECT_CHECK(VirtIOS390Bus, (obj), TYPE_S390_VIRTIO_BUS)
65 0d936928 Anthony Liguori
66 ea35d4f1 KONRAD Frederic
/* virtio-s390-bus */
67 ea35d4f1 KONRAD Frederic
68 ea35d4f1 KONRAD Frederic
typedef struct VirtioBusState VirtioS390BusState;
69 ea35d4f1 KONRAD Frederic
typedef struct VirtioBusClass VirtioS390BusClass;
70 ea35d4f1 KONRAD Frederic
71 ea35d4f1 KONRAD Frederic
#define TYPE_VIRTIO_S390_BUS "virtio-s390-bus"
72 ea35d4f1 KONRAD Frederic
#define VIRTIO_S390_BUS(obj) \
73 ea35d4f1 KONRAD Frederic
        OBJECT_CHECK(VirtioS390BusState, (obj), TYPE_VIRTIO_S390_BUS)
74 ea35d4f1 KONRAD Frederic
#define VIRTIO_S390_BUS_GET_CLASS(obj) \
75 ea35d4f1 KONRAD Frederic
        OBJECT_GET_CLASS(VirtioS390BusClass, obj, TYPE_VIRTIO_S390_BUS)
76 ea35d4f1 KONRAD Frederic
#define VIRTIO_S390_BUS_CLASS(klass) \
77 ea35d4f1 KONRAD Frederic
        OBJECT_CLASS_CHECK(VirtioS390BusClass, klass, TYPE_VIRTIO_S390_BUS)
78 ea35d4f1 KONRAD Frederic
79 ea35d4f1 KONRAD Frederic
80 39bffca2 Anthony Liguori
typedef struct VirtIOS390Device VirtIOS390Device;
81 39bffca2 Anthony Liguori
82 39bffca2 Anthony Liguori
typedef struct VirtIOS390DeviceClass {
83 39bffca2 Anthony Liguori
    DeviceClass qdev;
84 39bffca2 Anthony Liguori
    int (*init)(VirtIOS390Device *dev);
85 39bffca2 Anthony Liguori
} VirtIOS390DeviceClass;
86 39bffca2 Anthony Liguori
87 39bffca2 Anthony Liguori
struct VirtIOS390Device {
88 f3304eea Alexander Graf
    DeviceState qdev;
89 f3304eea Alexander Graf
    ram_addr_t dev_offs;
90 f3304eea Alexander Graf
    ram_addr_t feat_offs;
91 f3304eea Alexander Graf
    uint8_t feat_len;
92 f3304eea Alexander Graf
    VirtIODevice *vdev;
93 8172539d Michael S. Tsirkin
    uint32_t host_features;
94 11e9235b KONRAD Frederic
    VirtioBusState bus;
95 39bffca2 Anthony Liguori
};
96 f3304eea Alexander Graf
97 f3304eea Alexander Graf
typedef struct VirtIOS390Bus {
98 f3304eea Alexander Graf
    BusState bus;
99 f3304eea Alexander Graf
100 f3304eea Alexander Graf
    VirtIOS390Device *console;
101 f3304eea Alexander Graf
    ram_addr_t dev_page;
102 f3304eea Alexander Graf
    ram_addr_t dev_offs;
103 f3304eea Alexander Graf
    ram_addr_t next_ring;
104 f3304eea Alexander Graf
} VirtIOS390Bus;
105 f3304eea Alexander Graf
106 f3304eea Alexander Graf
107 64b85a8f Blue Swirl
void s390_virtio_device_update_status(VirtIOS390Device *dev);
108 f3304eea Alexander Graf
109 64b85a8f Blue Swirl
VirtIOS390Device *s390_virtio_bus_console(VirtIOS390Bus *bus);
110 64b85a8f Blue Swirl
VirtIOS390Bus *s390_virtio_bus_init(ram_addr_t *ram_size);
111 f3304eea Alexander Graf
112 64b85a8f Blue Swirl
VirtIOS390Device *s390_virtio_bus_find_vring(VirtIOS390Bus *bus,
113 64b85a8f Blue Swirl
                                             ram_addr_t mem, int *vq_num);
114 64b85a8f Blue Swirl
VirtIOS390Device *s390_virtio_bus_find_mem(VirtIOS390Bus *bus, ram_addr_t mem);
115 64b85a8f Blue Swirl
void s390_virtio_device_sync(VirtIOS390Device *dev);
116 4170aea1 Jens Freimann
void s390_virtio_reset_idx(VirtIOS390Device *dev);
117 4170aea1 Jens Freimann
118 55d11e01 KONRAD Frederic
/* virtio-blk-s390 */
119 55d11e01 KONRAD Frederic
120 55d11e01 KONRAD Frederic
#define TYPE_VIRTIO_BLK_S390 "virtio-blk-s390"
121 55d11e01 KONRAD Frederic
#define VIRTIO_BLK_S390(obj) \
122 55d11e01 KONRAD Frederic
        OBJECT_CHECK(VirtIOBlkS390, (obj), TYPE_VIRTIO_BLK_S390)
123 55d11e01 KONRAD Frederic
124 55d11e01 KONRAD Frederic
typedef struct VirtIOBlkS390 {
125 55d11e01 KONRAD Frederic
    VirtIOS390Device parent_obj;
126 55d11e01 KONRAD Frederic
    VirtIOBlock vdev;
127 55d11e01 KONRAD Frederic
    VirtIOBlkConf blk;
128 55d11e01 KONRAD Frederic
} VirtIOBlkS390;
129 55d11e01 KONRAD Frederic
130 9ef13d8f KONRAD Frederic
/* virtio-scsi-s390 */
131 9ef13d8f KONRAD Frederic
132 9ef13d8f KONRAD Frederic
#define TYPE_VIRTIO_SCSI_S390 "virtio-scsi-s390"
133 9ef13d8f KONRAD Frederic
#define VIRTIO_SCSI_S390(obj) \
134 9ef13d8f KONRAD Frederic
        OBJECT_CHECK(VirtIOSCSIS390, (obj), TYPE_VIRTIO_SCSI_S390)
135 9ef13d8f KONRAD Frederic
136 9ef13d8f KONRAD Frederic
typedef struct VirtIOSCSIS390 {
137 9ef13d8f KONRAD Frederic
    VirtIOS390Device parent_obj;
138 9ef13d8f KONRAD Frederic
    VirtIOSCSI vdev;
139 9ef13d8f KONRAD Frederic
} VirtIOSCSIS390;
140 cb9c377f Paolo Bonzini
141 55169140 KONRAD Frederic
/* virtio-serial-s390 */
142 55169140 KONRAD Frederic
143 55169140 KONRAD Frederic
#define TYPE_VIRTIO_SERIAL_S390 "virtio-serial-s390"
144 55169140 KONRAD Frederic
#define VIRTIO_SERIAL_S390(obj) \
145 55169140 KONRAD Frederic
        OBJECT_CHECK(VirtIOSerialS390, (obj), TYPE_VIRTIO_SERIAL_S390)
146 55169140 KONRAD Frederic
147 55169140 KONRAD Frederic
typedef struct VirtIOSerialS390 {
148 55169140 KONRAD Frederic
    VirtIOS390Device parent_obj;
149 55169140 KONRAD Frederic
    VirtIOSerial vdev;
150 55169140 KONRAD Frederic
} VirtIOSerialS390;
151 55169140 KONRAD Frederic
152 74b4fe3d KONRAD Frederic
/* virtio-net-s390 */
153 74b4fe3d KONRAD Frederic
154 74b4fe3d KONRAD Frederic
#define TYPE_VIRTIO_NET_S390 "virtio-net-s390"
155 74b4fe3d KONRAD Frederic
#define VIRTIO_NET_S390(obj) \
156 74b4fe3d KONRAD Frederic
        OBJECT_CHECK(VirtIONetS390, (obj), TYPE_VIRTIO_NET_S390)
157 74b4fe3d KONRAD Frederic
158 74b4fe3d KONRAD Frederic
typedef struct VirtIONetS390 {
159 74b4fe3d KONRAD Frederic
    VirtIOS390Device parent_obj;
160 74b4fe3d KONRAD Frederic
    VirtIONet vdev;
161 74b4fe3d KONRAD Frederic
} VirtIONetS390;
162 74b4fe3d KONRAD Frederic
163 d6e51919 Paolo Bonzini
/* vhost-scsi-s390 */
164 d6e51919 Paolo Bonzini
165 d6e51919 Paolo Bonzini
#ifdef CONFIG_VHOST_SCSI
166 d6e51919 Paolo Bonzini
#define TYPE_VHOST_SCSI_S390 "vhost-scsi-s390"
167 d6e51919 Paolo Bonzini
#define VHOST_SCSI_S390(obj) \
168 d6e51919 Paolo Bonzini
        OBJECT_CHECK(VHostSCSIS390, (obj), TYPE_VHOST_SCSI_S390)
169 d6e51919 Paolo Bonzini
170 d6e51919 Paolo Bonzini
typedef struct VHostSCSIS390 {
171 d6e51919 Paolo Bonzini
    VirtIOS390Device parent_obj;
172 d6e51919 Paolo Bonzini
    VHostSCSI vdev;
173 d6e51919 Paolo Bonzini
} VHostSCSIS390;
174 d6e51919 Paolo Bonzini
#endif
175 d6e51919 Paolo Bonzini
176 0bca1f53 KONRAD Frederic
/* virtio-rng-s390 */
177 0bca1f53 KONRAD Frederic
178 0bca1f53 KONRAD Frederic
#define TYPE_VIRTIO_RNG_S390 "virtio-rng-s390"
179 0bca1f53 KONRAD Frederic
#define VIRTIO_RNG_S390(obj) \
180 0bca1f53 KONRAD Frederic
        OBJECT_CHECK(VirtIORNGS390, (obj), TYPE_VIRTIO_RNG_S390)
181 0bca1f53 KONRAD Frederic
182 0bca1f53 KONRAD Frederic
typedef struct VirtIORNGS390 {
183 0bca1f53 KONRAD Frederic
    VirtIOS390Device parent_obj;
184 0bca1f53 KONRAD Frederic
    VirtIORNG vdev;
185 0bca1f53 KONRAD Frederic
} VirtIORNGS390;
186 0bca1f53 KONRAD Frederic
187 cb9c377f Paolo Bonzini
#endif