xref: /qemu/tests/qtest/libqos/virtio-mmio.h (revision 138ca49a)
1 /*
2  * libqos virtio MMIO 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_MMIO_H
11 #define LIBQOS_VIRTIO_MMIO_H
12 
13 #include "virtio.h"
14 #include "qgraph.h"
15 
16 #define QVIRTIO_MMIO_MAGIC_VALUE        0x000
17 #define QVIRTIO_MMIO_VERSION            0x004
18 #define QVIRTIO_MMIO_DEVICE_ID          0x008
19 #define QVIRTIO_MMIO_VENDOR_ID          0x00C
20 #define QVIRTIO_MMIO_HOST_FEATURES      0x010
21 #define QVIRTIO_MMIO_HOST_FEATURES_SEL  0x014
22 #define QVIRTIO_MMIO_GUEST_FEATURES     0x020
23 #define QVIRTIO_MMIO_GUEST_FEATURES_SEL 0x024
24 #define QVIRTIO_MMIO_GUEST_PAGE_SIZE    0x028
25 #define QVIRTIO_MMIO_QUEUE_SEL          0x030
26 #define QVIRTIO_MMIO_QUEUE_NUM_MAX      0x034
27 #define QVIRTIO_MMIO_QUEUE_NUM          0x038
28 #define QVIRTIO_MMIO_QUEUE_ALIGN        0x03C
29 #define QVIRTIO_MMIO_QUEUE_PFN          0x040
30 #define QVIRTIO_MMIO_QUEUE_NOTIFY       0x050
31 #define QVIRTIO_MMIO_INTERRUPT_STATUS   0x060
32 #define QVIRTIO_MMIO_INTERRUPT_ACK      0x064
33 #define QVIRTIO_MMIO_DEVICE_STATUS      0x070
34 #define QVIRTIO_MMIO_DEVICE_SPECIFIC    0x100
35 
36 typedef struct QVirtioMMIODevice {
37     QOSGraphObject obj;
38     QVirtioDevice vdev;
39     QTestState *qts;
40     uint64_t addr;
41     uint32_t page_size;
42     uint32_t features; /* As it cannot be read later, save it */
43     uint32_t version;
44 } QVirtioMMIODevice;
45 
46 extern const QVirtioBus qvirtio_mmio;
47 
48 void qvirtio_mmio_init_device(QVirtioMMIODevice *dev, QTestState *qts,
49                               uint64_t addr, uint32_t page_size);
50 
51 #endif
52