1 /* SPDX-License-Identifier: GPL-2.0+ */
3 * Copyright (C) 2018, Tuomas Tynkkynen <tuomas.tynkkynen@iki.fi>
4 * Copyright (C) 2018, Bin Meng <bmeng.cn@gmail.com>
6 * From Linux kernel include/uapi/linux/virtio_mmio.h
9 #ifndef _LINUX_VIRTIO_MMIO_H
10 #define _LINUX_VIRTIO_MMIO_H
12 /* Control registers */
14 /* Magic value ("virt" string) - Read Only */
15 #define VIRTIO_MMIO_MAGIC_VALUE 0x000
17 /* Virtio device version - Read Only */
18 #define VIRTIO_MMIO_VERSION 0x004
20 /* Virtio device ID - Read Only */
21 #define VIRTIO_MMIO_DEVICE_ID 0x008
23 /* Virtio vendor ID - Read Only */
24 #define VIRTIO_MMIO_VENDOR_ID 0x00c
27 * Bitmask of the features supported by the device (host)
28 * (32 bits per set) - Read Only
30 #define VIRTIO_MMIO_DEVICE_FEATURES 0x010
32 /* Device (host) features set selector - Write Only */
33 #define VIRTIO_MMIO_DEVICE_FEATURES_SEL 0x014
36 * Bitmask of features activated by the driver (guest)
37 * (32 bits per set) - Write Only
39 #define VIRTIO_MMIO_DRIVER_FEATURES 0x020
41 /* Activated features set selector - Write Only */
42 #define VIRTIO_MMIO_DRIVER_FEATURES_SEL 0x024
44 #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
46 /* Guest's memory page size in bytes - Write Only */
47 #define VIRTIO_MMIO_GUEST_PAGE_SIZE 0x028
51 /* Queue selector - Write Only */
52 #define VIRTIO_MMIO_QUEUE_SEL 0x030
54 /* Maximum size of the currently selected queue - Read Only */
55 #define VIRTIO_MMIO_QUEUE_NUM_MAX 0x034
57 /* Queue size for the currently selected queue - Write Only */
58 #define VIRTIO_MMIO_QUEUE_NUM 0x038
60 #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */
62 /* Used Ring alignment for the currently selected queue - Write Only */
63 #define VIRTIO_MMIO_QUEUE_ALIGN 0x03c
65 /* Guest's PFN for the currently selected queue - Read Write */
66 #define VIRTIO_MMIO_QUEUE_PFN 0x040
70 /* Ready bit for the currently selected queue - Read Write */
71 #define VIRTIO_MMIO_QUEUE_READY 0x044
73 /* Queue notifier - Write Only */
74 #define VIRTIO_MMIO_QUEUE_NOTIFY 0x050
76 /* Interrupt status - Read Only */
77 #define VIRTIO_MMIO_INTERRUPT_STATUS 0x060
79 /* Interrupt acknowledge - Write Only */
80 #define VIRTIO_MMIO_INTERRUPT_ACK 0x064
82 /* Device status register - Read Write */
83 #define VIRTIO_MMIO_STATUS 0x070
85 /* Selected queue's Descriptor Table address, 64 bits in two halves */
86 #define VIRTIO_MMIO_QUEUE_DESC_LOW 0x080
87 #define VIRTIO_MMIO_QUEUE_DESC_HIGH 0x084
89 /* Selected queue's Available Ring address, 64 bits in two halves */
90 #define VIRTIO_MMIO_QUEUE_AVAIL_LOW 0x090
91 #define VIRTIO_MMIO_QUEUE_AVAIL_HIGH 0x094
93 /* Selected queue's Used Ring address, 64 bits in two halves */
94 #define VIRTIO_MMIO_QUEUE_USED_LOW 0x0a0
95 #define VIRTIO_MMIO_QUEUE_USED_HIGH 0x0a4
97 /* Configuration atomicity value */
98 #define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc
101 * The config space is defined by each driver as
102 * the per-driver configuration space - Read Write
104 #define VIRTIO_MMIO_CONFIG 0x100
106 /* Interrupt flags (re: interrupt status & acknowledge registers) */
108 #define VIRTIO_MMIO_INT_VRING BIT(0)
109 #define VIRTIO_MMIO_INT_CONFIG BIT(1)
112 * The alignment to use between consumer and producer parts of vring.
113 * Currently hardcoded to the page size.
115 #define PAGE_SHIFT 12
116 #define VIRTIO_MMIO_VRING_ALIGN PAGE_SIZE
119 * virtio mmio transport driver private data
121 * @base: mmio transport device register base
122 * @version: mmio transport device version
124 struct virtio_mmio_priv {
129 #endif /* _LINUX_VIRTIO_MMIO_H */