xref: /openbmc/qemu/include/hw/virtio/virtio-mmio.h (revision 0221d73c)
1 /*
2  * Virtio MMIO bindings
3  *
4  * Copyright (c) 2011 Linaro Limited
5  *
6  * Author:
7  *  Peter Maydell <peter.maydell@linaro.org>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License; either version 2
11  * of the License, or (at your option) any later version.
12  *
13  * This program is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU General Public License for more details.
17  *
18  * You should have received a copy of the GNU General Public License along
19  * with this program; if not, see <http://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef HW_VIRTIO_MMIO_H
23 #define HW_VIRTIO_MMIO_H
24 
25 #include "hw/virtio/virtio-bus.h"
26 
27 /* QOM macros */
28 /* virtio-mmio-bus */
29 #define TYPE_VIRTIO_MMIO_BUS "virtio-mmio-bus"
30 #define VIRTIO_MMIO_BUS(obj) \
31         OBJECT_CHECK(VirtioBusState, (obj), TYPE_VIRTIO_MMIO_BUS)
32 #define VIRTIO_MMIO_BUS_GET_CLASS(obj) \
33         OBJECT_GET_CLASS(VirtioBusClass, (obj), TYPE_VIRTIO_MMIO_BUS)
34 #define VIRTIO_MMIO_BUS_CLASS(klass) \
35         OBJECT_CLASS_CHECK(VirtioBusClass, (klass), TYPE_VIRTIO_MMIO_BUS)
36 
37 /* virtio-mmio */
38 #define TYPE_VIRTIO_MMIO "virtio-mmio"
39 #define VIRTIO_MMIO(obj) \
40         OBJECT_CHECK(VirtIOMMIOProxy, (obj), TYPE_VIRTIO_MMIO)
41 
42 #define VIRT_MAGIC 0x74726976 /* 'virt' */
43 #define VIRT_VERSION 2
44 #define VIRT_VERSION_LEGACY 1
45 #define VIRT_VENDOR 0x554D4551 /* 'QEMU' */
46 
47 typedef struct VirtIOMMIOQueue {
48     uint16_t num;
49     bool enabled;
50     uint32_t desc[2];
51     uint32_t avail[2];
52     uint32_t used[2];
53 } VirtIOMMIOQueue;
54 
55 typedef struct {
56     /* Generic */
57     SysBusDevice parent_obj;
58     MemoryRegion iomem;
59     qemu_irq irq;
60     bool legacy;
61     /* Guest accessible state needing migration and reset */
62     uint32_t host_features_sel;
63     uint32_t guest_features_sel;
64     uint32_t guest_page_shift;
65     /* virtio-bus */
66     VirtioBusState bus;
67     bool format_transport_address;
68     /* Fields only used for non-legacy (v2) devices */
69     uint32_t guest_features[2];
70     VirtIOMMIOQueue vqs[VIRTIO_QUEUE_MAX];
71 } VirtIOMMIOProxy;
72 
73 #endif
74