]> git.proxmox.com Git - mirror_qemu.git/blob - tests/libqos/virtio.c
tests: Add virtio device initialization
[mirror_qemu.git] / tests / libqos / virtio.c
1 /*
2 * libqos virtio driver
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 #include <glib.h>
11 #include "libqtest.h"
12 #include "libqos/virtio.h"
13
14 uint8_t qvirtio_config_readb(const QVirtioBus *bus, QVirtioDevice *d,
15 void *addr)
16 {
17 return bus->config_readb(d, addr);
18 }
19
20 uint16_t qvirtio_config_readw(const QVirtioBus *bus, QVirtioDevice *d,
21 void *addr)
22 {
23 return bus->config_readw(d, addr);
24 }
25
26 uint32_t qvirtio_config_readl(const QVirtioBus *bus, QVirtioDevice *d,
27 void *addr)
28 {
29 return bus->config_readl(d, addr);
30 }
31
32 uint64_t qvirtio_config_readq(const QVirtioBus *bus, QVirtioDevice *d,
33 void *addr)
34 {
35 return bus->config_readq(d, addr);
36 }
37
38 void qvirtio_reset(const QVirtioBus *bus, QVirtioDevice *d)
39 {
40 bus->set_status(d, QVIRTIO_RESET);
41 g_assert_cmphex(bus->get_status(d), ==, QVIRTIO_RESET);
42 }
43
44 void qvirtio_set_acknowledge(const QVirtioBus *bus, QVirtioDevice *d)
45 {
46 bus->set_status(d, bus->get_status(d) | QVIRTIO_ACKNOWLEDGE);
47 g_assert_cmphex(bus->get_status(d), ==, QVIRTIO_ACKNOWLEDGE);
48 }
49
50 void qvirtio_set_driver(const QVirtioBus *bus, QVirtioDevice *d)
51 {
52 bus->set_status(d, bus->get_status(d) | QVIRTIO_DRIVER);
53 g_assert_cmphex(bus->get_status(d), ==,
54 QVIRTIO_DRIVER | QVIRTIO_ACKNOWLEDGE);
55 }