]> git.proxmox.com Git - mirror_qemu.git/blob - tests/libqos/virtio.h
tests: Add virtio device initialization
[mirror_qemu.git] / tests / libqos / virtio.h
1 /*
2 * libqos virtio definitions
3 *
4 * Copyright (c) 2014 Marc MarĂ­
5 *
6 * This work is licensed under the terms of the GNU GPL, version 2 or later.
7 * See the COPYING file in the top-level directory.
8 */
9
10 #ifndef LIBQOS_VIRTIO_H
11 #define LIBQOS_VIRTIO_H
12
13 #define QVIRTIO_VENDOR_ID 0x1AF4
14
15 #define QVIRTIO_RESET 0x0
16 #define QVIRTIO_ACKNOWLEDGE 0x1
17 #define QVIRTIO_DRIVER 0x2
18
19 #define QVIRTIO_NET_DEVICE_ID 0x1
20 #define QVIRTIO_BLK_DEVICE_ID 0x2
21
22 typedef struct QVirtioDevice {
23 /* Device type */
24 uint16_t device_type;
25 } QVirtioDevice;
26
27 typedef struct QVirtioBus {
28 uint8_t (*config_readb)(QVirtioDevice *d, void *addr);
29 uint16_t (*config_readw)(QVirtioDevice *d, void *addr);
30 uint32_t (*config_readl)(QVirtioDevice *d, void *addr);
31 uint64_t (*config_readq)(QVirtioDevice *d, void *addr);
32
33 /* Get status of the device */
34 uint8_t (*get_status)(QVirtioDevice *d);
35
36 /* Set status of the device */
37 void (*set_status)(QVirtioDevice *d, uint8_t status);
38 } QVirtioBus;
39
40 uint8_t qvirtio_config_readb(const QVirtioBus *bus, QVirtioDevice *d,
41 void *addr);
42 uint16_t qvirtio_config_readw(const QVirtioBus *bus, QVirtioDevice *d,
43 void *addr);
44 uint32_t qvirtio_config_readl(const QVirtioBus *bus, QVirtioDevice *d,
45 void *addr);
46 uint64_t qvirtio_config_readq(const QVirtioBus *bus, QVirtioDevice *d,
47 void *addr);
48
49 void qvirtio_reset(const QVirtioBus *bus, QVirtioDevice *d);
50 void qvirtio_set_acknowledge(const QVirtioBus *bus, QVirtioDevice *d);
51 void qvirtio_set_driver(const QVirtioBus *bus, QVirtioDevice *d);
52
53 #endif