root / hw / virtio-pci.c @ 7ed208c4
History | View | Annotate | Download (17.9 kB)
1 | 53c25cea | Paul Brook | /*
|
---|---|---|---|
2 | 53c25cea | Paul Brook | * Virtio PCI Bindings
|
3 | 53c25cea | Paul Brook | *
|
4 | 53c25cea | Paul Brook | * Copyright IBM, Corp. 2007
|
5 | 53c25cea | Paul Brook | * Copyright (c) 2009 CodeSourcery
|
6 | 53c25cea | Paul Brook | *
|
7 | 53c25cea | Paul Brook | * Authors:
|
8 | 53c25cea | Paul Brook | * Anthony Liguori <aliguori@us.ibm.com>
|
9 | 53c25cea | Paul Brook | * Paul Brook <paul@codesourcery.com>
|
10 | 53c25cea | Paul Brook | *
|
11 | 53c25cea | Paul Brook | * This work is licensed under the terms of the GNU GPL, version 2. See
|
12 | 53c25cea | Paul Brook | * the COPYING file in the top-level directory.
|
13 | 53c25cea | Paul Brook | *
|
14 | 53c25cea | Paul Brook | */
|
15 | 53c25cea | Paul Brook | |
16 | 53c25cea | Paul Brook | #include <inttypes.h> |
17 | 53c25cea | Paul Brook | |
18 | 53c25cea | Paul Brook | #include "virtio.h" |
19 | 53c25cea | Paul Brook | #include "pci.h" |
20 | 1ad2134f | Paul Brook | //#include "sysemu.h"
|
21 | aba800a3 | Michael S. Tsirkin | #include "msix.h" |
22 | a1e0fea5 | Gerd Hoffmann | #include "net.h" |
23 | 53c25cea | Paul Brook | |
24 | 53c25cea | Paul Brook | /* from Linux's linux/virtio_pci.h */
|
25 | 53c25cea | Paul Brook | |
26 | 53c25cea | Paul Brook | /* A 32-bit r/o bitmask of the features supported by the host */
|
27 | 53c25cea | Paul Brook | #define VIRTIO_PCI_HOST_FEATURES 0 |
28 | 53c25cea | Paul Brook | |
29 | 53c25cea | Paul Brook | /* A 32-bit r/w bitmask of features activated by the guest */
|
30 | 53c25cea | Paul Brook | #define VIRTIO_PCI_GUEST_FEATURES 4 |
31 | 53c25cea | Paul Brook | |
32 | 53c25cea | Paul Brook | /* A 32-bit r/w PFN for the currently selected queue */
|
33 | 53c25cea | Paul Brook | #define VIRTIO_PCI_QUEUE_PFN 8 |
34 | 53c25cea | Paul Brook | |
35 | 53c25cea | Paul Brook | /* A 16-bit r/o queue size for the currently selected queue */
|
36 | 53c25cea | Paul Brook | #define VIRTIO_PCI_QUEUE_NUM 12 |
37 | 53c25cea | Paul Brook | |
38 | 53c25cea | Paul Brook | /* A 16-bit r/w queue selector */
|
39 | 53c25cea | Paul Brook | #define VIRTIO_PCI_QUEUE_SEL 14 |
40 | 53c25cea | Paul Brook | |
41 | 53c25cea | Paul Brook | /* A 16-bit r/w queue notifier */
|
42 | 53c25cea | Paul Brook | #define VIRTIO_PCI_QUEUE_NOTIFY 16 |
43 | 53c25cea | Paul Brook | |
44 | 53c25cea | Paul Brook | /* An 8-bit device status register. */
|
45 | 53c25cea | Paul Brook | #define VIRTIO_PCI_STATUS 18 |
46 | 53c25cea | Paul Brook | |
47 | 53c25cea | Paul Brook | /* An 8-bit r/o interrupt status register. Reading the value will return the
|
48 | 53c25cea | Paul Brook | * current contents of the ISR and will also clear it. This is effectively
|
49 | 53c25cea | Paul Brook | * a read-and-acknowledge. */
|
50 | 53c25cea | Paul Brook | #define VIRTIO_PCI_ISR 19 |
51 | 53c25cea | Paul Brook | |
52 | aba800a3 | Michael S. Tsirkin | /* MSI-X registers: only enabled if MSI-X is enabled. */
|
53 | aba800a3 | Michael S. Tsirkin | /* A 16-bit vector for configuration changes. */
|
54 | aba800a3 | Michael S. Tsirkin | #define VIRTIO_MSI_CONFIG_VECTOR 20 |
55 | aba800a3 | Michael S. Tsirkin | /* A 16-bit vector for selected queue notifications. */
|
56 | aba800a3 | Michael S. Tsirkin | #define VIRTIO_MSI_QUEUE_VECTOR 22 |
57 | aba800a3 | Michael S. Tsirkin | |
58 | aba800a3 | Michael S. Tsirkin | /* Config space size */
|
59 | aba800a3 | Michael S. Tsirkin | #define VIRTIO_PCI_CONFIG_NOMSI 20 |
60 | aba800a3 | Michael S. Tsirkin | #define VIRTIO_PCI_CONFIG_MSI 24 |
61 | aba800a3 | Michael S. Tsirkin | #define VIRTIO_PCI_REGION_SIZE(dev) (msix_present(dev) ? \
|
62 | aba800a3 | Michael S. Tsirkin | VIRTIO_PCI_CONFIG_MSI : \ |
63 | aba800a3 | Michael S. Tsirkin | VIRTIO_PCI_CONFIG_NOMSI) |
64 | aba800a3 | Michael S. Tsirkin | |
65 | aba800a3 | Michael S. Tsirkin | /* The remaining space is defined by each driver as the per-driver
|
66 | aba800a3 | Michael S. Tsirkin | * configuration space */
|
67 | aba800a3 | Michael S. Tsirkin | #define VIRTIO_PCI_CONFIG(dev) (msix_enabled(dev) ? \
|
68 | aba800a3 | Michael S. Tsirkin | VIRTIO_PCI_CONFIG_MSI : \ |
69 | aba800a3 | Michael S. Tsirkin | VIRTIO_PCI_CONFIG_NOMSI) |
70 | 53c25cea | Paul Brook | |
71 | 53c25cea | Paul Brook | /* Virtio ABI version, if we increment this, we break the guest driver. */
|
72 | 53c25cea | Paul Brook | #define VIRTIO_PCI_ABI_VERSION 0 |
73 | 53c25cea | Paul Brook | |
74 | 53c25cea | Paul Brook | /* How many bits to shift physical queue address written to QUEUE_PFN.
|
75 | 53c25cea | Paul Brook | * 12 is historical, and due to x86 page size. */
|
76 | 53c25cea | Paul Brook | #define VIRTIO_PCI_QUEUE_ADDR_SHIFT 12 |
77 | 53c25cea | Paul Brook | |
78 | 53c25cea | Paul Brook | /* QEMU doesn't strictly need write barriers since everything runs in
|
79 | 53c25cea | Paul Brook | * lock-step. We'll leave the calls to wmb() in though to make it obvious for
|
80 | 53c25cea | Paul Brook | * KVM or if kqemu gets SMP support.
|
81 | 53c25cea | Paul Brook | */
|
82 | 53c25cea | Paul Brook | #define wmb() do { } while (0) |
83 | 53c25cea | Paul Brook | |
84 | 53c25cea | Paul Brook | /* PCI bindings. */
|
85 | 53c25cea | Paul Brook | |
86 | 53c25cea | Paul Brook | typedef struct { |
87 | 53c25cea | Paul Brook | PCIDevice pci_dev; |
88 | 53c25cea | Paul Brook | VirtIODevice *vdev; |
89 | 53c25cea | Paul Brook | uint32_t addr; |
90 | ab73ff29 | Gerd Hoffmann | uint32_t class_code; |
91 | a1e0fea5 | Gerd Hoffmann | uint32_t nvectors; |
92 | 53c25cea | Paul Brook | } VirtIOPCIProxy; |
93 | 53c25cea | Paul Brook | |
94 | 53c25cea | Paul Brook | /* virtio device */
|
95 | 53c25cea | Paul Brook | |
96 | 7055e687 | Michael S. Tsirkin | static void virtio_pci_notify(void *opaque, uint16_t vector) |
97 | 53c25cea | Paul Brook | { |
98 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = opaque; |
99 | aba800a3 | Michael S. Tsirkin | if (msix_enabled(&proxy->pci_dev))
|
100 | aba800a3 | Michael S. Tsirkin | msix_notify(&proxy->pci_dev, vector); |
101 | aba800a3 | Michael S. Tsirkin | else
|
102 | aba800a3 | Michael S. Tsirkin | qemu_set_irq(proxy->pci_dev.irq[0], proxy->vdev->isr & 1); |
103 | 53c25cea | Paul Brook | } |
104 | 53c25cea | Paul Brook | |
105 | ff24bd58 | Michael S. Tsirkin | static void virtio_pci_save_config(void * opaque, QEMUFile *f) |
106 | ff24bd58 | Michael S. Tsirkin | { |
107 | ff24bd58 | Michael S. Tsirkin | VirtIOPCIProxy *proxy = opaque; |
108 | ff24bd58 | Michael S. Tsirkin | pci_device_save(&proxy->pci_dev, f); |
109 | ff24bd58 | Michael S. Tsirkin | msix_save(&proxy->pci_dev, f); |
110 | ff24bd58 | Michael S. Tsirkin | if (msix_present(&proxy->pci_dev))
|
111 | ff24bd58 | Michael S. Tsirkin | qemu_put_be16(f, proxy->vdev->config_vector); |
112 | ff24bd58 | Michael S. Tsirkin | } |
113 | ff24bd58 | Michael S. Tsirkin | |
114 | ff24bd58 | Michael S. Tsirkin | static void virtio_pci_save_queue(void * opaque, int n, QEMUFile *f) |
115 | ff24bd58 | Michael S. Tsirkin | { |
116 | ff24bd58 | Michael S. Tsirkin | VirtIOPCIProxy *proxy = opaque; |
117 | ff24bd58 | Michael S. Tsirkin | if (msix_present(&proxy->pci_dev))
|
118 | ff24bd58 | Michael S. Tsirkin | qemu_put_be16(f, virtio_queue_vector(proxy->vdev, n)); |
119 | ff24bd58 | Michael S. Tsirkin | } |
120 | ff24bd58 | Michael S. Tsirkin | |
121 | ff24bd58 | Michael S. Tsirkin | static int virtio_pci_load_config(void * opaque, QEMUFile *f) |
122 | ff24bd58 | Michael S. Tsirkin | { |
123 | ff24bd58 | Michael S. Tsirkin | VirtIOPCIProxy *proxy = opaque; |
124 | ff24bd58 | Michael S. Tsirkin | int ret;
|
125 | ff24bd58 | Michael S. Tsirkin | ret = pci_device_load(&proxy->pci_dev, f); |
126 | e6da7680 | Michael S. Tsirkin | if (ret) {
|
127 | ff24bd58 | Michael S. Tsirkin | return ret;
|
128 | e6da7680 | Michael S. Tsirkin | } |
129 | ff24bd58 | Michael S. Tsirkin | msix_load(&proxy->pci_dev, f); |
130 | e6da7680 | Michael S. Tsirkin | if (msix_present(&proxy->pci_dev)) {
|
131 | ff24bd58 | Michael S. Tsirkin | qemu_get_be16s(f, &proxy->vdev->config_vector); |
132 | e6da7680 | Michael S. Tsirkin | } else {
|
133 | e6da7680 | Michael S. Tsirkin | proxy->vdev->config_vector = VIRTIO_NO_VECTOR; |
134 | e6da7680 | Michael S. Tsirkin | } |
135 | e6da7680 | Michael S. Tsirkin | if (proxy->vdev->config_vector != VIRTIO_NO_VECTOR) {
|
136 | e6da7680 | Michael S. Tsirkin | return msix_vector_use(&proxy->pci_dev, proxy->vdev->config_vector);
|
137 | e6da7680 | Michael S. Tsirkin | } |
138 | ff24bd58 | Michael S. Tsirkin | return 0; |
139 | ff24bd58 | Michael S. Tsirkin | } |
140 | ff24bd58 | Michael S. Tsirkin | |
141 | ff24bd58 | Michael S. Tsirkin | static int virtio_pci_load_queue(void * opaque, int n, QEMUFile *f) |
142 | ff24bd58 | Michael S. Tsirkin | { |
143 | ff24bd58 | Michael S. Tsirkin | VirtIOPCIProxy *proxy = opaque; |
144 | ff24bd58 | Michael S. Tsirkin | uint16_t vector; |
145 | e6da7680 | Michael S. Tsirkin | if (msix_present(&proxy->pci_dev)) {
|
146 | e6da7680 | Michael S. Tsirkin | qemu_get_be16s(f, &vector); |
147 | e6da7680 | Michael S. Tsirkin | } else {
|
148 | e6da7680 | Michael S. Tsirkin | vector = VIRTIO_NO_VECTOR; |
149 | e6da7680 | Michael S. Tsirkin | } |
150 | ff24bd58 | Michael S. Tsirkin | virtio_queue_set_vector(proxy->vdev, n, vector); |
151 | e6da7680 | Michael S. Tsirkin | if (vector != VIRTIO_NO_VECTOR) {
|
152 | e6da7680 | Michael S. Tsirkin | return msix_vector_use(&proxy->pci_dev, vector);
|
153 | e6da7680 | Michael S. Tsirkin | } |
154 | ff24bd58 | Michael S. Tsirkin | return 0; |
155 | ff24bd58 | Michael S. Tsirkin | } |
156 | ff24bd58 | Michael S. Tsirkin | |
157 | 7055e687 | Michael S. Tsirkin | static void virtio_pci_reset(void *opaque) |
158 | 7055e687 | Michael S. Tsirkin | { |
159 | 7055e687 | Michael S. Tsirkin | VirtIOPCIProxy *proxy = opaque; |
160 | 7055e687 | Michael S. Tsirkin | virtio_reset(proxy->vdev); |
161 | aba800a3 | Michael S. Tsirkin | msix_reset(&proxy->pci_dev); |
162 | 7055e687 | Michael S. Tsirkin | } |
163 | 7055e687 | Michael S. Tsirkin | |
164 | 53c25cea | Paul Brook | static void virtio_ioport_write(void *opaque, uint32_t addr, uint32_t val) |
165 | 53c25cea | Paul Brook | { |
166 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = opaque; |
167 | 53c25cea | Paul Brook | VirtIODevice *vdev = proxy->vdev; |
168 | 53c25cea | Paul Brook | target_phys_addr_t pa; |
169 | 53c25cea | Paul Brook | |
170 | 53c25cea | Paul Brook | switch (addr) {
|
171 | 53c25cea | Paul Brook | case VIRTIO_PCI_GUEST_FEATURES:
|
172 | 53c25cea | Paul Brook | /* Guest does not negotiate properly? We have to assume nothing. */
|
173 | 53c25cea | Paul Brook | if (val & (1 << VIRTIO_F_BAD_FEATURE)) { |
174 | 53c25cea | Paul Brook | if (vdev->bad_features)
|
175 | 53c25cea | Paul Brook | val = vdev->bad_features(vdev); |
176 | 53c25cea | Paul Brook | else
|
177 | 53c25cea | Paul Brook | val = 0;
|
178 | 53c25cea | Paul Brook | } |
179 | 53c25cea | Paul Brook | if (vdev->set_features)
|
180 | 53c25cea | Paul Brook | vdev->set_features(vdev, val); |
181 | 53c25cea | Paul Brook | vdev->features = val; |
182 | 53c25cea | Paul Brook | break;
|
183 | 53c25cea | Paul Brook | case VIRTIO_PCI_QUEUE_PFN:
|
184 | 53c25cea | Paul Brook | pa = (target_phys_addr_t)val << VIRTIO_PCI_QUEUE_ADDR_SHIFT; |
185 | 7055e687 | Michael S. Tsirkin | if (pa == 0) |
186 | 7055e687 | Michael S. Tsirkin | virtio_pci_reset(proxy); |
187 | 7055e687 | Michael S. Tsirkin | else
|
188 | 7055e687 | Michael S. Tsirkin | virtio_queue_set_addr(vdev, vdev->queue_sel, pa); |
189 | 53c25cea | Paul Brook | break;
|
190 | 53c25cea | Paul Brook | case VIRTIO_PCI_QUEUE_SEL:
|
191 | 53c25cea | Paul Brook | if (val < VIRTIO_PCI_QUEUE_MAX)
|
192 | 53c25cea | Paul Brook | vdev->queue_sel = val; |
193 | 53c25cea | Paul Brook | break;
|
194 | 53c25cea | Paul Brook | case VIRTIO_PCI_QUEUE_NOTIFY:
|
195 | 53c25cea | Paul Brook | virtio_queue_notify(vdev, val); |
196 | 53c25cea | Paul Brook | break;
|
197 | 53c25cea | Paul Brook | case VIRTIO_PCI_STATUS:
|
198 | 53c25cea | Paul Brook | vdev->status = val & 0xFF;
|
199 | 53c25cea | Paul Brook | if (vdev->status == 0) |
200 | 7055e687 | Michael S. Tsirkin | virtio_pci_reset(proxy); |
201 | 53c25cea | Paul Brook | break;
|
202 | aba800a3 | Michael S. Tsirkin | case VIRTIO_MSI_CONFIG_VECTOR:
|
203 | aba800a3 | Michael S. Tsirkin | msix_vector_unuse(&proxy->pci_dev, vdev->config_vector); |
204 | aba800a3 | Michael S. Tsirkin | /* Make it possible for guest to discover an error took place. */
|
205 | aba800a3 | Michael S. Tsirkin | if (msix_vector_use(&proxy->pci_dev, val) < 0) |
206 | aba800a3 | Michael S. Tsirkin | val = VIRTIO_NO_VECTOR; |
207 | aba800a3 | Michael S. Tsirkin | vdev->config_vector = val; |
208 | aba800a3 | Michael S. Tsirkin | break;
|
209 | aba800a3 | Michael S. Tsirkin | case VIRTIO_MSI_QUEUE_VECTOR:
|
210 | aba800a3 | Michael S. Tsirkin | msix_vector_unuse(&proxy->pci_dev, |
211 | aba800a3 | Michael S. Tsirkin | virtio_queue_vector(vdev, vdev->queue_sel)); |
212 | aba800a3 | Michael S. Tsirkin | /* Make it possible for guest to discover an error took place. */
|
213 | aba800a3 | Michael S. Tsirkin | if (msix_vector_use(&proxy->pci_dev, val) < 0) |
214 | aba800a3 | Michael S. Tsirkin | val = VIRTIO_NO_VECTOR; |
215 | aba800a3 | Michael S. Tsirkin | virtio_queue_set_vector(vdev, vdev->queue_sel, val); |
216 | aba800a3 | Michael S. Tsirkin | break;
|
217 | aba800a3 | Michael S. Tsirkin | default:
|
218 | aba800a3 | Michael S. Tsirkin | fprintf(stderr, "%s: unexpected address 0x%x value 0x%x\n",
|
219 | aba800a3 | Michael S. Tsirkin | __func__, addr, val); |
220 | aba800a3 | Michael S. Tsirkin | break;
|
221 | 53c25cea | Paul Brook | } |
222 | 53c25cea | Paul Brook | } |
223 | 53c25cea | Paul Brook | |
224 | aba800a3 | Michael S. Tsirkin | static uint32_t virtio_ioport_read(VirtIOPCIProxy *proxy, uint32_t addr)
|
225 | 53c25cea | Paul Brook | { |
226 | 53c25cea | Paul Brook | VirtIODevice *vdev = proxy->vdev; |
227 | 53c25cea | Paul Brook | uint32_t ret = 0xFFFFFFFF;
|
228 | 53c25cea | Paul Brook | |
229 | 53c25cea | Paul Brook | switch (addr) {
|
230 | 53c25cea | Paul Brook | case VIRTIO_PCI_HOST_FEATURES:
|
231 | 53c25cea | Paul Brook | ret = vdev->get_features(vdev); |
232 | efeea6d0 | Mark McLoughlin | ret |= (1 << VIRTIO_F_NOTIFY_ON_EMPTY);
|
233 | efeea6d0 | Mark McLoughlin | ret |= (1 << VIRTIO_RING_F_INDIRECT_DESC);
|
234 | efeea6d0 | Mark McLoughlin | ret |= (1 << VIRTIO_F_BAD_FEATURE);
|
235 | 53c25cea | Paul Brook | break;
|
236 | 53c25cea | Paul Brook | case VIRTIO_PCI_GUEST_FEATURES:
|
237 | 53c25cea | Paul Brook | ret = vdev->features; |
238 | 53c25cea | Paul Brook | break;
|
239 | 53c25cea | Paul Brook | case VIRTIO_PCI_QUEUE_PFN:
|
240 | 53c25cea | Paul Brook | ret = virtio_queue_get_addr(vdev, vdev->queue_sel) |
241 | 53c25cea | Paul Brook | >> VIRTIO_PCI_QUEUE_ADDR_SHIFT; |
242 | 53c25cea | Paul Brook | break;
|
243 | 53c25cea | Paul Brook | case VIRTIO_PCI_QUEUE_NUM:
|
244 | 53c25cea | Paul Brook | ret = virtio_queue_get_num(vdev, vdev->queue_sel); |
245 | 53c25cea | Paul Brook | break;
|
246 | 53c25cea | Paul Brook | case VIRTIO_PCI_QUEUE_SEL:
|
247 | 53c25cea | Paul Brook | ret = vdev->queue_sel; |
248 | 53c25cea | Paul Brook | break;
|
249 | 53c25cea | Paul Brook | case VIRTIO_PCI_STATUS:
|
250 | 53c25cea | Paul Brook | ret = vdev->status; |
251 | 53c25cea | Paul Brook | break;
|
252 | 53c25cea | Paul Brook | case VIRTIO_PCI_ISR:
|
253 | 53c25cea | Paul Brook | /* reading from the ISR also clears it. */
|
254 | 53c25cea | Paul Brook | ret = vdev->isr; |
255 | 53c25cea | Paul Brook | vdev->isr = 0;
|
256 | 7055e687 | Michael S. Tsirkin | qemu_set_irq(proxy->pci_dev.irq[0], 0); |
257 | 53c25cea | Paul Brook | break;
|
258 | aba800a3 | Michael S. Tsirkin | case VIRTIO_MSI_CONFIG_VECTOR:
|
259 | aba800a3 | Michael S. Tsirkin | ret = vdev->config_vector; |
260 | aba800a3 | Michael S. Tsirkin | break;
|
261 | aba800a3 | Michael S. Tsirkin | case VIRTIO_MSI_QUEUE_VECTOR:
|
262 | aba800a3 | Michael S. Tsirkin | ret = virtio_queue_vector(vdev, vdev->queue_sel); |
263 | aba800a3 | Michael S. Tsirkin | break;
|
264 | 53c25cea | Paul Brook | default:
|
265 | 53c25cea | Paul Brook | break;
|
266 | 53c25cea | Paul Brook | } |
267 | 53c25cea | Paul Brook | |
268 | 53c25cea | Paul Brook | return ret;
|
269 | 53c25cea | Paul Brook | } |
270 | 53c25cea | Paul Brook | |
271 | 53c25cea | Paul Brook | static uint32_t virtio_pci_config_readb(void *opaque, uint32_t addr) |
272 | 53c25cea | Paul Brook | { |
273 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = opaque; |
274 | aba800a3 | Michael S. Tsirkin | uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); |
275 | aba800a3 | Michael S. Tsirkin | addr -= proxy->addr; |
276 | aba800a3 | Michael S. Tsirkin | if (addr < config)
|
277 | aba800a3 | Michael S. Tsirkin | return virtio_ioport_read(proxy, addr);
|
278 | aba800a3 | Michael S. Tsirkin | addr -= config; |
279 | 53c25cea | Paul Brook | return virtio_config_readb(proxy->vdev, addr);
|
280 | 53c25cea | Paul Brook | } |
281 | 53c25cea | Paul Brook | |
282 | 53c25cea | Paul Brook | static uint32_t virtio_pci_config_readw(void *opaque, uint32_t addr) |
283 | 53c25cea | Paul Brook | { |
284 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = opaque; |
285 | aba800a3 | Michael S. Tsirkin | uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); |
286 | aba800a3 | Michael S. Tsirkin | addr -= proxy->addr; |
287 | aba800a3 | Michael S. Tsirkin | if (addr < config)
|
288 | aba800a3 | Michael S. Tsirkin | return virtio_ioport_read(proxy, addr);
|
289 | aba800a3 | Michael S. Tsirkin | addr -= config; |
290 | 53c25cea | Paul Brook | return virtio_config_readw(proxy->vdev, addr);
|
291 | 53c25cea | Paul Brook | } |
292 | 53c25cea | Paul Brook | |
293 | 53c25cea | Paul Brook | static uint32_t virtio_pci_config_readl(void *opaque, uint32_t addr) |
294 | 53c25cea | Paul Brook | { |
295 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = opaque; |
296 | aba800a3 | Michael S. Tsirkin | uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); |
297 | aba800a3 | Michael S. Tsirkin | addr -= proxy->addr; |
298 | aba800a3 | Michael S. Tsirkin | if (addr < config)
|
299 | aba800a3 | Michael S. Tsirkin | return virtio_ioport_read(proxy, addr);
|
300 | aba800a3 | Michael S. Tsirkin | addr -= config; |
301 | 53c25cea | Paul Brook | return virtio_config_readl(proxy->vdev, addr);
|
302 | 53c25cea | Paul Brook | } |
303 | 53c25cea | Paul Brook | |
304 | 53c25cea | Paul Brook | static void virtio_pci_config_writeb(void *opaque, uint32_t addr, uint32_t val) |
305 | 53c25cea | Paul Brook | { |
306 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = opaque; |
307 | aba800a3 | Michael S. Tsirkin | uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); |
308 | aba800a3 | Michael S. Tsirkin | addr -= proxy->addr; |
309 | aba800a3 | Michael S. Tsirkin | if (addr < config) {
|
310 | aba800a3 | Michael S. Tsirkin | virtio_ioport_write(proxy, addr, val); |
311 | aba800a3 | Michael S. Tsirkin | return;
|
312 | aba800a3 | Michael S. Tsirkin | } |
313 | aba800a3 | Michael S. Tsirkin | addr -= config; |
314 | 53c25cea | Paul Brook | virtio_config_writeb(proxy->vdev, addr, val); |
315 | 53c25cea | Paul Brook | } |
316 | 53c25cea | Paul Brook | |
317 | 53c25cea | Paul Brook | static void virtio_pci_config_writew(void *opaque, uint32_t addr, uint32_t val) |
318 | 53c25cea | Paul Brook | { |
319 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = opaque; |
320 | aba800a3 | Michael S. Tsirkin | uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); |
321 | aba800a3 | Michael S. Tsirkin | addr -= proxy->addr; |
322 | aba800a3 | Michael S. Tsirkin | if (addr < config) {
|
323 | aba800a3 | Michael S. Tsirkin | virtio_ioport_write(proxy, addr, val); |
324 | aba800a3 | Michael S. Tsirkin | return;
|
325 | aba800a3 | Michael S. Tsirkin | } |
326 | aba800a3 | Michael S. Tsirkin | addr -= config; |
327 | 53c25cea | Paul Brook | virtio_config_writew(proxy->vdev, addr, val); |
328 | 53c25cea | Paul Brook | } |
329 | 53c25cea | Paul Brook | |
330 | 53c25cea | Paul Brook | static void virtio_pci_config_writel(void *opaque, uint32_t addr, uint32_t val) |
331 | 53c25cea | Paul Brook | { |
332 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = opaque; |
333 | aba800a3 | Michael S. Tsirkin | uint32_t config = VIRTIO_PCI_CONFIG(&proxy->pci_dev); |
334 | aba800a3 | Michael S. Tsirkin | addr -= proxy->addr; |
335 | aba800a3 | Michael S. Tsirkin | if (addr < config) {
|
336 | aba800a3 | Michael S. Tsirkin | virtio_ioport_write(proxy, addr, val); |
337 | aba800a3 | Michael S. Tsirkin | return;
|
338 | aba800a3 | Michael S. Tsirkin | } |
339 | aba800a3 | Michael S. Tsirkin | addr -= config; |
340 | 53c25cea | Paul Brook | virtio_config_writel(proxy->vdev, addr, val); |
341 | 53c25cea | Paul Brook | } |
342 | 53c25cea | Paul Brook | |
343 | 53c25cea | Paul Brook | static void virtio_map(PCIDevice *pci_dev, int region_num, |
344 | 53c25cea | Paul Brook | uint32_t addr, uint32_t size, int type)
|
345 | 53c25cea | Paul Brook | { |
346 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = container_of(pci_dev, VirtIOPCIProxy, pci_dev); |
347 | 53c25cea | Paul Brook | VirtIODevice *vdev = proxy->vdev; |
348 | aba800a3 | Michael S. Tsirkin | unsigned config_len = VIRTIO_PCI_REGION_SIZE(pci_dev) + vdev->config_len;
|
349 | 53c25cea | Paul Brook | |
350 | 53c25cea | Paul Brook | proxy->addr = addr; |
351 | 53c25cea | Paul Brook | |
352 | aba800a3 | Michael S. Tsirkin | register_ioport_write(addr, config_len, 1, virtio_pci_config_writeb, proxy);
|
353 | aba800a3 | Michael S. Tsirkin | register_ioport_write(addr, config_len, 2, virtio_pci_config_writew, proxy);
|
354 | aba800a3 | Michael S. Tsirkin | register_ioport_write(addr, config_len, 4, virtio_pci_config_writel, proxy);
|
355 | aba800a3 | Michael S. Tsirkin | register_ioport_read(addr, config_len, 1, virtio_pci_config_readb, proxy);
|
356 | aba800a3 | Michael S. Tsirkin | register_ioport_read(addr, config_len, 2, virtio_pci_config_readw, proxy);
|
357 | aba800a3 | Michael S. Tsirkin | register_ioport_read(addr, config_len, 4, virtio_pci_config_readl, proxy);
|
358 | 53c25cea | Paul Brook | |
359 | aba800a3 | Michael S. Tsirkin | if (vdev->config_len)
|
360 | 53c25cea | Paul Brook | vdev->get_config(vdev, vdev->config); |
361 | aba800a3 | Michael S. Tsirkin | } |
362 | aba800a3 | Michael S. Tsirkin | |
363 | aba800a3 | Michael S. Tsirkin | static void virtio_write_config(PCIDevice *pci_dev, uint32_t address, |
364 | aba800a3 | Michael S. Tsirkin | uint32_t val, int len)
|
365 | aba800a3 | Michael S. Tsirkin | { |
366 | aba800a3 | Michael S. Tsirkin | pci_default_write_config(pci_dev, address, val, len); |
367 | aba800a3 | Michael S. Tsirkin | msix_write_config(pci_dev, address, val, len); |
368 | 53c25cea | Paul Brook | } |
369 | 53c25cea | Paul Brook | |
370 | 53c25cea | Paul Brook | static const VirtIOBindings virtio_pci_bindings = { |
371 | ff24bd58 | Michael S. Tsirkin | .notify = virtio_pci_notify, |
372 | ff24bd58 | Michael S. Tsirkin | .save_config = virtio_pci_save_config, |
373 | ff24bd58 | Michael S. Tsirkin | .load_config = virtio_pci_load_config, |
374 | ff24bd58 | Michael S. Tsirkin | .save_queue = virtio_pci_save_queue, |
375 | ff24bd58 | Michael S. Tsirkin | .load_queue = virtio_pci_load_queue, |
376 | 53c25cea | Paul Brook | }; |
377 | 53c25cea | Paul Brook | |
378 | 53c25cea | Paul Brook | static void virtio_init_pci(VirtIOPCIProxy *proxy, VirtIODevice *vdev, |
379 | 53c25cea | Paul Brook | uint16_t vendor, uint16_t device, |
380 | 53c25cea | Paul Brook | uint16_t class_code, uint8_t pif) |
381 | 53c25cea | Paul Brook | { |
382 | 53c25cea | Paul Brook | uint8_t *config; |
383 | 53c25cea | Paul Brook | uint32_t size; |
384 | 53c25cea | Paul Brook | |
385 | 53c25cea | Paul Brook | proxy->vdev = vdev; |
386 | 53c25cea | Paul Brook | |
387 | 53c25cea | Paul Brook | config = proxy->pci_dev.config; |
388 | 53c25cea | Paul Brook | pci_config_set_vendor_id(config, vendor); |
389 | 53c25cea | Paul Brook | pci_config_set_device_id(config, device); |
390 | 53c25cea | Paul Brook | |
391 | 53c25cea | Paul Brook | config[0x08] = VIRTIO_PCI_ABI_VERSION;
|
392 | 53c25cea | Paul Brook | |
393 | 53c25cea | Paul Brook | config[0x09] = pif;
|
394 | 53c25cea | Paul Brook | pci_config_set_class(config, class_code); |
395 | 53c25cea | Paul Brook | config[PCI_HEADER_TYPE] = PCI_HEADER_TYPE_NORMAL; |
396 | 53c25cea | Paul Brook | |
397 | 53c25cea | Paul Brook | config[0x2c] = vendor & 0xFF; |
398 | 53c25cea | Paul Brook | config[0x2d] = (vendor >> 8) & 0xFF; |
399 | 53c25cea | Paul Brook | config[0x2e] = vdev->device_id & 0xFF; |
400 | 53c25cea | Paul Brook | config[0x2f] = (vdev->device_id >> 8) & 0xFF; |
401 | 53c25cea | Paul Brook | |
402 | 53c25cea | Paul Brook | config[0x3d] = 1; |
403 | 53c25cea | Paul Brook | |
404 | aba800a3 | Michael S. Tsirkin | if (vdev->nvectors && !msix_init(&proxy->pci_dev, vdev->nvectors, 1, 0)) { |
405 | aba800a3 | Michael S. Tsirkin | pci_register_bar(&proxy->pci_dev, 1,
|
406 | aba800a3 | Michael S. Tsirkin | msix_bar_size(&proxy->pci_dev), |
407 | aba800a3 | Michael S. Tsirkin | PCI_ADDRESS_SPACE_MEM, |
408 | aba800a3 | Michael S. Tsirkin | msix_mmio_map); |
409 | aba800a3 | Michael S. Tsirkin | proxy->pci_dev.config_write = virtio_write_config; |
410 | aba800a3 | Michael S. Tsirkin | proxy->pci_dev.unregister = msix_uninit; |
411 | aba800a3 | Michael S. Tsirkin | } else
|
412 | aba800a3 | Michael S. Tsirkin | vdev->nvectors = 0;
|
413 | aba800a3 | Michael S. Tsirkin | |
414 | aba800a3 | Michael S. Tsirkin | size = VIRTIO_PCI_REGION_SIZE(&proxy->pci_dev) + vdev->config_len; |
415 | 53c25cea | Paul Brook | if (size & (size-1)) |
416 | 53c25cea | Paul Brook | size = 1 << qemu_fls(size);
|
417 | 53c25cea | Paul Brook | |
418 | 28c2c264 | Avi Kivity | pci_register_bar(&proxy->pci_dev, 0, size, PCI_ADDRESS_SPACE_IO,
|
419 | 53c25cea | Paul Brook | virtio_map); |
420 | 53c25cea | Paul Brook | |
421 | a08d4367 | Jan Kiszka | qemu_register_reset(virtio_pci_reset, proxy); |
422 | 7055e687 | Michael S. Tsirkin | |
423 | 53c25cea | Paul Brook | virtio_bind_device(vdev, &virtio_pci_bindings, proxy); |
424 | 53c25cea | Paul Brook | } |
425 | 53c25cea | Paul Brook | |
426 | 5c634ef3 | Mark McLoughlin | static void virtio_blk_init_pci_with_class(PCIDevice *pci_dev, |
427 | 5c634ef3 | Mark McLoughlin | uint16_t class_code) |
428 | 53c25cea | Paul Brook | { |
429 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); |
430 | 53c25cea | Paul Brook | VirtIODevice *vdev; |
431 | 53c25cea | Paul Brook | |
432 | 53c25cea | Paul Brook | vdev = virtio_blk_init(&pci_dev->qdev); |
433 | 53c25cea | Paul Brook | virtio_init_pci(proxy, vdev, |
434 | 53c25cea | Paul Brook | PCI_VENDOR_ID_REDHAT_QUMRANET, |
435 | 53c25cea | Paul Brook | PCI_DEVICE_ID_VIRTIO_BLOCK, |
436 | 5c634ef3 | Mark McLoughlin | class_code, 0x00);
|
437 | 5c634ef3 | Mark McLoughlin | } |
438 | 5c634ef3 | Mark McLoughlin | |
439 | 5c634ef3 | Mark McLoughlin | static void virtio_blk_init_pci(PCIDevice *pci_dev) |
440 | 5c634ef3 | Mark McLoughlin | { |
441 | ab73ff29 | Gerd Hoffmann | VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); |
442 | ab73ff29 | Gerd Hoffmann | |
443 | ab73ff29 | Gerd Hoffmann | if (proxy->class_code != PCI_CLASS_STORAGE_SCSI &&
|
444 | ab73ff29 | Gerd Hoffmann | proxy->class_code != PCI_CLASS_STORAGE_OTHER) |
445 | ab73ff29 | Gerd Hoffmann | proxy->class_code = PCI_CLASS_STORAGE_SCSI; |
446 | ab73ff29 | Gerd Hoffmann | |
447 | ab73ff29 | Gerd Hoffmann | virtio_blk_init_pci_with_class(pci_dev, proxy->class_code); |
448 | 5c634ef3 | Mark McLoughlin | } |
449 | 5c634ef3 | Mark McLoughlin | |
450 | 5c634ef3 | Mark McLoughlin | static void virtio_blk_init_pci_0_10(PCIDevice *pci_dev) |
451 | 5c634ef3 | Mark McLoughlin | { |
452 | 5c634ef3 | Mark McLoughlin | virtio_blk_init_pci_with_class(pci_dev, PCI_CLASS_STORAGE_OTHER); |
453 | 53c25cea | Paul Brook | } |
454 | 53c25cea | Paul Brook | |
455 | 21d58b57 | Mark McLoughlin | static void virtio_console_init_pci_with_class(PCIDevice *pci_dev, |
456 | 21d58b57 | Mark McLoughlin | uint16_t class_code) |
457 | 53c25cea | Paul Brook | { |
458 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); |
459 | 53c25cea | Paul Brook | VirtIODevice *vdev; |
460 | 53c25cea | Paul Brook | |
461 | 53c25cea | Paul Brook | vdev = virtio_console_init(&pci_dev->qdev); |
462 | 53c25cea | Paul Brook | virtio_init_pci(proxy, vdev, |
463 | 53c25cea | Paul Brook | PCI_VENDOR_ID_REDHAT_QUMRANET, |
464 | 53c25cea | Paul Brook | PCI_DEVICE_ID_VIRTIO_CONSOLE, |
465 | 21d58b57 | Mark McLoughlin | class_code, 0x00);
|
466 | 21d58b57 | Mark McLoughlin | } |
467 | 21d58b57 | Mark McLoughlin | |
468 | 21d58b57 | Mark McLoughlin | static void virtio_console_init_pci(PCIDevice *pci_dev) |
469 | 21d58b57 | Mark McLoughlin | { |
470 | d6beee99 | Gerd Hoffmann | VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); |
471 | d6beee99 | Gerd Hoffmann | |
472 | d6beee99 | Gerd Hoffmann | if (proxy->class_code != PCI_CLASS_COMMUNICATION_OTHER &&
|
473 | d6beee99 | Gerd Hoffmann | proxy->class_code != PCI_CLASS_DISPLAY_OTHER && /* qemu 0.10 */
|
474 | d6beee99 | Gerd Hoffmann | proxy->class_code != PCI_CLASS_OTHERS) /* qemu-kvm */
|
475 | d6beee99 | Gerd Hoffmann | proxy->class_code = PCI_CLASS_COMMUNICATION_OTHER; |
476 | d6beee99 | Gerd Hoffmann | |
477 | d6beee99 | Gerd Hoffmann | virtio_console_init_pci_with_class(pci_dev, proxy->class_code); |
478 | 21d58b57 | Mark McLoughlin | } |
479 | 21d58b57 | Mark McLoughlin | |
480 | 21d58b57 | Mark McLoughlin | static void virtio_console_init_pci_0_10(PCIDevice *pci_dev) |
481 | 21d58b57 | Mark McLoughlin | { |
482 | 21d58b57 | Mark McLoughlin | virtio_console_init_pci_with_class(pci_dev, PCI_CLASS_DISPLAY_OTHER); |
483 | 53c25cea | Paul Brook | } |
484 | 53c25cea | Paul Brook | |
485 | 53c25cea | Paul Brook | static void virtio_net_init_pci(PCIDevice *pci_dev) |
486 | 53c25cea | Paul Brook | { |
487 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); |
488 | 53c25cea | Paul Brook | VirtIODevice *vdev; |
489 | 53c25cea | Paul Brook | |
490 | 53c25cea | Paul Brook | vdev = virtio_net_init(&pci_dev->qdev); |
491 | a1e0fea5 | Gerd Hoffmann | |
492 | a1e0fea5 | Gerd Hoffmann | /* set nvectors from property, unless the user specified something
|
493 | a1e0fea5 | Gerd Hoffmann | * via -net nic,model=virtio,vectors=n command line option */
|
494 | a1e0fea5 | Gerd Hoffmann | if (pci_dev->qdev.nd->nvectors == NIC_NVECTORS_UNSPECIFIED)
|
495 | a1e0fea5 | Gerd Hoffmann | if (proxy->nvectors != NIC_NVECTORS_UNSPECIFIED)
|
496 | a1e0fea5 | Gerd Hoffmann | vdev->nvectors = proxy->nvectors; |
497 | a1e0fea5 | Gerd Hoffmann | |
498 | 53c25cea | Paul Brook | virtio_init_pci(proxy, vdev, |
499 | 53c25cea | Paul Brook | PCI_VENDOR_ID_REDHAT_QUMRANET, |
500 | 53c25cea | Paul Brook | PCI_DEVICE_ID_VIRTIO_NET, |
501 | 53c25cea | Paul Brook | PCI_CLASS_NETWORK_ETHERNET, |
502 | 53c25cea | Paul Brook | 0x00);
|
503 | a1e0fea5 | Gerd Hoffmann | |
504 | a1e0fea5 | Gerd Hoffmann | /* make the actual value visible */
|
505 | a1e0fea5 | Gerd Hoffmann | proxy->nvectors = vdev->nvectors; |
506 | 53c25cea | Paul Brook | } |
507 | 53c25cea | Paul Brook | |
508 | 53c25cea | Paul Brook | static void virtio_balloon_init_pci(PCIDevice *pci_dev) |
509 | 53c25cea | Paul Brook | { |
510 | 53c25cea | Paul Brook | VirtIOPCIProxy *proxy = DO_UPCAST(VirtIOPCIProxy, pci_dev, pci_dev); |
511 | 53c25cea | Paul Brook | VirtIODevice *vdev; |
512 | 53c25cea | Paul Brook | |
513 | 53c25cea | Paul Brook | vdev = virtio_balloon_init(&pci_dev->qdev); |
514 | 53c25cea | Paul Brook | virtio_init_pci(proxy, vdev, |
515 | 53c25cea | Paul Brook | PCI_VENDOR_ID_REDHAT_QUMRANET, |
516 | 53c25cea | Paul Brook | PCI_DEVICE_ID_VIRTIO_BALLOON, |
517 | 53c25cea | Paul Brook | PCI_CLASS_MEMORY_RAM, |
518 | 53c25cea | Paul Brook | 0x00);
|
519 | 53c25cea | Paul Brook | } |
520 | 53c25cea | Paul Brook | |
521 | 0aab0d3a | Gerd Hoffmann | static PCIDeviceInfo virtio_info[] = {
|
522 | 0aab0d3a | Gerd Hoffmann | { |
523 | 0aab0d3a | Gerd Hoffmann | .qdev.name = "virtio-blk-pci",
|
524 | 0aab0d3a | Gerd Hoffmann | .qdev.size = sizeof(VirtIOPCIProxy),
|
525 | 0aab0d3a | Gerd Hoffmann | .init = virtio_blk_init_pci, |
526 | ab73ff29 | Gerd Hoffmann | .qdev.props = (Property[]) { |
527 | ab73ff29 | Gerd Hoffmann | { |
528 | ab73ff29 | Gerd Hoffmann | .name = "class",
|
529 | ab73ff29 | Gerd Hoffmann | .info = &qdev_prop_hex32, |
530 | ab73ff29 | Gerd Hoffmann | .offset = offsetof(VirtIOPCIProxy, class_code), |
531 | ab73ff29 | Gerd Hoffmann | }, |
532 | ab73ff29 | Gerd Hoffmann | {/* end of list */}
|
533 | ab73ff29 | Gerd Hoffmann | }, |
534 | 0aab0d3a | Gerd Hoffmann | },{ |
535 | a1e0fea5 | Gerd Hoffmann | .qdev.name = "virtio-net-pci",
|
536 | a1e0fea5 | Gerd Hoffmann | .qdev.size = sizeof(VirtIOPCIProxy),
|
537 | a1e0fea5 | Gerd Hoffmann | .init = virtio_net_init_pci, |
538 | a1e0fea5 | Gerd Hoffmann | .qdev.props = (Property[]) { |
539 | a1e0fea5 | Gerd Hoffmann | { |
540 | a1e0fea5 | Gerd Hoffmann | .name = "vectors",
|
541 | a1e0fea5 | Gerd Hoffmann | .info = &qdev_prop_uint32, |
542 | a1e0fea5 | Gerd Hoffmann | .offset = offsetof(VirtIOPCIProxy, nvectors), |
543 | a1e0fea5 | Gerd Hoffmann | .defval = (uint32_t[]) { NIC_NVECTORS_UNSPECIFIED }, |
544 | a1e0fea5 | Gerd Hoffmann | }, |
545 | a1e0fea5 | Gerd Hoffmann | {/* end of list */}
|
546 | a1e0fea5 | Gerd Hoffmann | }, |
547 | 0aab0d3a | Gerd Hoffmann | },{ |
548 | 0aab0d3a | Gerd Hoffmann | .qdev.name = "virtio-console-pci",
|
549 | 0aab0d3a | Gerd Hoffmann | .qdev.size = sizeof(VirtIOPCIProxy),
|
550 | 0aab0d3a | Gerd Hoffmann | .init = virtio_console_init_pci, |
551 | d6beee99 | Gerd Hoffmann | .qdev.props = (Property[]) { |
552 | d6beee99 | Gerd Hoffmann | { |
553 | d6beee99 | Gerd Hoffmann | .name = "class",
|
554 | d6beee99 | Gerd Hoffmann | .info = &qdev_prop_hex32, |
555 | d6beee99 | Gerd Hoffmann | .offset = offsetof(VirtIOPCIProxy, class_code), |
556 | d6beee99 | Gerd Hoffmann | }, |
557 | d6beee99 | Gerd Hoffmann | {/* end of list */}
|
558 | d6beee99 | Gerd Hoffmann | }, |
559 | 0aab0d3a | Gerd Hoffmann | },{ |
560 | 0aab0d3a | Gerd Hoffmann | .qdev.name = "virtio-balloon-pci",
|
561 | 0aab0d3a | Gerd Hoffmann | .qdev.size = sizeof(VirtIOPCIProxy),
|
562 | 0aab0d3a | Gerd Hoffmann | .init = virtio_balloon_init_pci, |
563 | 0aab0d3a | Gerd Hoffmann | },{ |
564 | 5c634ef3 | Mark McLoughlin | /* For compatibility with 0.10 */
|
565 | 5c634ef3 | Mark McLoughlin | .qdev.name = "virtio-blk-pci-0-10",
|
566 | 5c634ef3 | Mark McLoughlin | .qdev.size = sizeof(VirtIOPCIProxy),
|
567 | 5c634ef3 | Mark McLoughlin | .init = virtio_blk_init_pci_0_10, |
568 | 5c634ef3 | Mark McLoughlin | },{ |
569 | 21d58b57 | Mark McLoughlin | .qdev.name = "virtio-console-pci-0-10",
|
570 | 21d58b57 | Mark McLoughlin | .qdev.size = sizeof(VirtIOPCIProxy),
|
571 | 21d58b57 | Mark McLoughlin | .init = virtio_console_init_pci_0_10, |
572 | 21d58b57 | Mark McLoughlin | },{ |
573 | 0aab0d3a | Gerd Hoffmann | /* end of list */
|
574 | 0aab0d3a | Gerd Hoffmann | } |
575 | 0aab0d3a | Gerd Hoffmann | }; |
576 | 0aab0d3a | Gerd Hoffmann | |
577 | 53c25cea | Paul Brook | static void virtio_pci_register_devices(void) |
578 | 53c25cea | Paul Brook | { |
579 | 0aab0d3a | Gerd Hoffmann | pci_qdev_register_many(virtio_info); |
580 | 53c25cea | Paul Brook | } |
581 | 53c25cea | Paul Brook | |
582 | 53c25cea | Paul Brook | device_init(virtio_pci_register_devices) |