raspi: fix SD card with recent sdhci changes
[qemu/cris-port.git] / hw / virtio / virtio-pci.h
blobe096e989c01d0537e9038bd0f6fbabd316d3b636
1 /*
2 * Virtio PCI Bindings
4 * Copyright IBM, Corp. 2007
5 * Copyright (c) 2009 CodeSourcery
7 * Authors:
8 * Anthony Liguori <aliguori@us.ibm.com>
9 * Paul Brook <paul@codesourcery.com>
11 * This work is licensed under the terms of the GNU GPL, version 2. See
12 * the COPYING file in the top-level directory.
15 #ifndef QEMU_VIRTIO_PCI_H
16 #define QEMU_VIRTIO_PCI_H
18 #include "hw/pci/msi.h"
19 #include "hw/virtio/virtio-blk.h"
20 #include "hw/virtio/virtio-net.h"
21 #include "hw/virtio/virtio-rng.h"
22 #include "hw/virtio/virtio-serial.h"
23 #include "hw/virtio/virtio-scsi.h"
24 #include "hw/virtio/virtio-balloon.h"
25 #include "hw/virtio/virtio-bus.h"
26 #include "hw/virtio/virtio-input.h"
27 #include "hw/virtio/virtio-gpu.h"
28 #ifdef CONFIG_VIRTFS
29 #include "hw/9pfs/virtio-9p.h"
30 #endif
31 #ifdef CONFIG_VHOST_SCSI
32 #include "hw/virtio/vhost-scsi.h"
33 #endif
35 typedef struct VirtIOPCIProxy VirtIOPCIProxy;
36 typedef struct VirtIOBlkPCI VirtIOBlkPCI;
37 typedef struct VirtIOSCSIPCI VirtIOSCSIPCI;
38 typedef struct VirtIOBalloonPCI VirtIOBalloonPCI;
39 typedef struct VirtIOSerialPCI VirtIOSerialPCI;
40 typedef struct VirtIONetPCI VirtIONetPCI;
41 typedef struct VHostSCSIPCI VHostSCSIPCI;
42 typedef struct VirtIORngPCI VirtIORngPCI;
43 typedef struct VirtIOInputPCI VirtIOInputPCI;
44 typedef struct VirtIOInputHIDPCI VirtIOInputHIDPCI;
45 typedef struct VirtIOInputHostPCI VirtIOInputHostPCI;
46 typedef struct VirtIOGPUPCI VirtIOGPUPCI;
48 /* virtio-pci-bus */
50 typedef struct VirtioBusState VirtioPCIBusState;
51 typedef struct VirtioBusClass VirtioPCIBusClass;
53 #define TYPE_VIRTIO_PCI_BUS "virtio-pci-bus"
54 #define VIRTIO_PCI_BUS(obj) \
55 OBJECT_CHECK(VirtioPCIBusState, (obj), TYPE_VIRTIO_PCI_BUS)
56 #define VIRTIO_PCI_BUS_GET_CLASS(obj) \
57 OBJECT_GET_CLASS(VirtioPCIBusClass, obj, TYPE_VIRTIO_PCI_BUS)
58 #define VIRTIO_PCI_BUS_CLASS(klass) \
59 OBJECT_CLASS_CHECK(VirtioPCIBusClass, klass, TYPE_VIRTIO_PCI_BUS)
61 /* Need to activate work-arounds for buggy guests at vmstate load. */
62 #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT 0
63 #define VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION \
64 (1 << VIRTIO_PCI_FLAG_BUS_MASTER_BUG_MIGRATION_BIT)
66 /* Performance improves when virtqueue kick processing is decoupled from the
67 * vcpu thread using ioeventfd for some devices. */
68 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT 1
69 #define VIRTIO_PCI_FLAG_USE_IOEVENTFD (1 << VIRTIO_PCI_FLAG_USE_IOEVENTFD_BIT)
71 /* virtio version flags */
72 #define VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT 2
73 #define VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT 3
74 #define VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT 4
75 #define VIRTIO_PCI_FLAG_DISABLE_LEGACY (1 << VIRTIO_PCI_FLAG_DISABLE_LEGACY_BIT)
76 #define VIRTIO_PCI_FLAG_DISABLE_MODERN (1 << VIRTIO_PCI_FLAG_DISABLE_MODERN_BIT)
77 #define VIRTIO_PCI_FLAG_DISABLE_PCIE (1 << VIRTIO_PCI_FLAG_DISABLE_PCIE_BIT)
79 /* migrate extra state */
80 #define VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT 4
81 #define VIRTIO_PCI_FLAG_MIGRATE_EXTRA (1 << VIRTIO_PCI_FLAG_MIGRATE_EXTRA_BIT)
83 /* have pio notification for modern device ? */
84 #define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT 5
85 #define VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY \
86 (1 << VIRTIO_PCI_FLAG_MODERN_PIO_NOTIFY_BIT)
88 typedef struct {
89 MSIMessage msg;
90 int virq;
91 unsigned int users;
92 } VirtIOIRQFD;
95 * virtio-pci: This is the PCIDevice which has a virtio-pci-bus.
97 #define TYPE_VIRTIO_PCI "virtio-pci"
98 #define VIRTIO_PCI_GET_CLASS(obj) \
99 OBJECT_GET_CLASS(VirtioPCIClass, obj, TYPE_VIRTIO_PCI)
100 #define VIRTIO_PCI_CLASS(klass) \
101 OBJECT_CLASS_CHECK(VirtioPCIClass, klass, TYPE_VIRTIO_PCI)
102 #define VIRTIO_PCI(obj) \
103 OBJECT_CHECK(VirtIOPCIProxy, (obj), TYPE_VIRTIO_PCI)
105 typedef struct VirtioPCIClass {
106 PCIDeviceClass parent_class;
107 DeviceRealize parent_dc_realize;
108 void (*realize)(VirtIOPCIProxy *vpci_dev, Error **errp);
109 } VirtioPCIClass;
111 typedef struct VirtIOPCIRegion {
112 MemoryRegion mr;
113 uint32_t offset;
114 uint32_t size;
115 uint32_t type;
116 } VirtIOPCIRegion;
118 typedef struct VirtIOPCIQueue {
119 uint16_t num;
120 bool enabled;
121 uint32_t desc[2];
122 uint32_t avail[2];
123 uint32_t used[2];
124 } VirtIOPCIQueue;
126 struct VirtIOPCIProxy {
127 PCIDevice pci_dev;
128 MemoryRegion bar;
129 VirtIOPCIRegion common;
130 VirtIOPCIRegion isr;
131 VirtIOPCIRegion device;
132 VirtIOPCIRegion notify;
133 VirtIOPCIRegion notify_pio;
134 MemoryRegion modern_bar;
135 MemoryRegion io_bar;
136 MemoryRegion modern_cfg;
137 AddressSpace modern_as;
138 uint32_t legacy_io_bar;
139 uint32_t msix_bar;
140 uint32_t modern_io_bar;
141 uint32_t modern_mem_bar;
142 int config_cap;
143 uint32_t flags;
144 uint32_t class_code;
145 uint32_t nvectors;
146 uint32_t dfselect;
147 uint32_t gfselect;
148 uint32_t guest_features[2];
149 VirtIOPCIQueue vqs[VIRTIO_QUEUE_MAX];
151 bool ioeventfd_disabled;
152 bool ioeventfd_started;
153 VirtIOIRQFD *vector_irqfd;
154 int nvqs_with_notifiers;
155 VirtioBusState bus;
160 * virtio-scsi-pci: This extends VirtioPCIProxy.
162 #define TYPE_VIRTIO_SCSI_PCI "virtio-scsi-pci"
163 #define VIRTIO_SCSI_PCI(obj) \
164 OBJECT_CHECK(VirtIOSCSIPCI, (obj), TYPE_VIRTIO_SCSI_PCI)
166 struct VirtIOSCSIPCI {
167 VirtIOPCIProxy parent_obj;
168 VirtIOSCSI vdev;
171 #ifdef CONFIG_VHOST_SCSI
173 * vhost-scsi-pci: This extends VirtioPCIProxy.
175 #define TYPE_VHOST_SCSI_PCI "vhost-scsi-pci"
176 #define VHOST_SCSI_PCI(obj) \
177 OBJECT_CHECK(VHostSCSIPCI, (obj), TYPE_VHOST_SCSI_PCI)
179 struct VHostSCSIPCI {
180 VirtIOPCIProxy parent_obj;
181 VHostSCSI vdev;
183 #endif
186 * virtio-blk-pci: This extends VirtioPCIProxy.
188 #define TYPE_VIRTIO_BLK_PCI "virtio-blk-pci"
189 #define VIRTIO_BLK_PCI(obj) \
190 OBJECT_CHECK(VirtIOBlkPCI, (obj), TYPE_VIRTIO_BLK_PCI)
192 struct VirtIOBlkPCI {
193 VirtIOPCIProxy parent_obj;
194 VirtIOBlock vdev;
198 * virtio-balloon-pci: This extends VirtioPCIProxy.
200 #define TYPE_VIRTIO_BALLOON_PCI "virtio-balloon-pci"
201 #define VIRTIO_BALLOON_PCI(obj) \
202 OBJECT_CHECK(VirtIOBalloonPCI, (obj), TYPE_VIRTIO_BALLOON_PCI)
204 struct VirtIOBalloonPCI {
205 VirtIOPCIProxy parent_obj;
206 VirtIOBalloon vdev;
210 * virtio-serial-pci: This extends VirtioPCIProxy.
212 #define TYPE_VIRTIO_SERIAL_PCI "virtio-serial-pci"
213 #define VIRTIO_SERIAL_PCI(obj) \
214 OBJECT_CHECK(VirtIOSerialPCI, (obj), TYPE_VIRTIO_SERIAL_PCI)
216 struct VirtIOSerialPCI {
217 VirtIOPCIProxy parent_obj;
218 VirtIOSerial vdev;
222 * virtio-net-pci: This extends VirtioPCIProxy.
224 #define TYPE_VIRTIO_NET_PCI "virtio-net-pci"
225 #define VIRTIO_NET_PCI(obj) \
226 OBJECT_CHECK(VirtIONetPCI, (obj), TYPE_VIRTIO_NET_PCI)
228 struct VirtIONetPCI {
229 VirtIOPCIProxy parent_obj;
230 VirtIONet vdev;
234 * virtio-9p-pci: This extends VirtioPCIProxy.
237 #ifdef CONFIG_VIRTFS
239 #define TYPE_VIRTIO_9P_PCI "virtio-9p-pci"
240 #define VIRTIO_9P_PCI(obj) \
241 OBJECT_CHECK(V9fsPCIState, (obj), TYPE_VIRTIO_9P_PCI)
243 typedef struct V9fsPCIState {
244 VirtIOPCIProxy parent_obj;
245 V9fsVirtioState vdev;
246 } V9fsPCIState;
248 #endif
251 * virtio-rng-pci: This extends VirtioPCIProxy.
253 #define TYPE_VIRTIO_RNG_PCI "virtio-rng-pci"
254 #define VIRTIO_RNG_PCI(obj) \
255 OBJECT_CHECK(VirtIORngPCI, (obj), TYPE_VIRTIO_RNG_PCI)
257 struct VirtIORngPCI {
258 VirtIOPCIProxy parent_obj;
259 VirtIORNG vdev;
263 * virtio-input-pci: This extends VirtioPCIProxy.
265 #define TYPE_VIRTIO_INPUT_PCI "virtio-input-pci"
266 #define VIRTIO_INPUT_PCI(obj) \
267 OBJECT_CHECK(VirtIOInputPCI, (obj), TYPE_VIRTIO_INPUT_PCI)
269 struct VirtIOInputPCI {
270 VirtIOPCIProxy parent_obj;
271 VirtIOInput vdev;
274 #define TYPE_VIRTIO_INPUT_HID_PCI "virtio-input-hid-pci"
275 #define TYPE_VIRTIO_KEYBOARD_PCI "virtio-keyboard-pci"
276 #define TYPE_VIRTIO_MOUSE_PCI "virtio-mouse-pci"
277 #define TYPE_VIRTIO_TABLET_PCI "virtio-tablet-pci"
278 #define VIRTIO_INPUT_HID_PCI(obj) \
279 OBJECT_CHECK(VirtIOInputHIDPCI, (obj), TYPE_VIRTIO_INPUT_HID_PCI)
281 struct VirtIOInputHIDPCI {
282 VirtIOPCIProxy parent_obj;
283 VirtIOInputHID vdev;
286 #ifdef CONFIG_LINUX
288 #define TYPE_VIRTIO_INPUT_HOST_PCI "virtio-input-host-pci"
289 #define VIRTIO_INPUT_HOST_PCI(obj) \
290 OBJECT_CHECK(VirtIOInputHostPCI, (obj), TYPE_VIRTIO_INPUT_HOST_PCI)
292 struct VirtIOInputHostPCI {
293 VirtIOPCIProxy parent_obj;
294 VirtIOInputHost vdev;
297 #endif
300 * virtio-gpu-pci: This extends VirtioPCIProxy.
302 #define TYPE_VIRTIO_GPU_PCI "virtio-gpu-pci"
303 #define VIRTIO_GPU_PCI(obj) \
304 OBJECT_CHECK(VirtIOGPUPCI, (obj), TYPE_VIRTIO_GPU_PCI)
306 struct VirtIOGPUPCI {
307 VirtIOPCIProxy parent_obj;
308 VirtIOGPU vdev;
311 /* Virtio ABI version, if we increment this, we break the guest driver. */
312 #define VIRTIO_PCI_ABI_VERSION 0
314 #endif