1*5878b136SMichael S. Tsirkin /* 2*5878b136SMichael S. Tsirkin * Virtio platform device driver 3*5878b136SMichael S. Tsirkin * 4*5878b136SMichael S. Tsirkin * Copyright 2011, ARM Ltd. 5*5878b136SMichael S. Tsirkin * 6*5878b136SMichael S. Tsirkin * Based on Virtio PCI driver by Anthony Liguori, copyright IBM Corp. 2007 7*5878b136SMichael S. Tsirkin * 8*5878b136SMichael S. Tsirkin * This header is BSD licensed so anyone can use the definitions to implement 9*5878b136SMichael S. Tsirkin * compatible drivers/servers. 10*5878b136SMichael S. Tsirkin * 11*5878b136SMichael S. Tsirkin * Redistribution and use in source and binary forms, with or without 12*5878b136SMichael S. Tsirkin * modification, are permitted provided that the following conditions 13*5878b136SMichael S. Tsirkin * are met: 14*5878b136SMichael S. Tsirkin * 1. Redistributions of source code must retain the above copyright 15*5878b136SMichael S. Tsirkin * notice, this list of conditions and the following disclaimer. 16*5878b136SMichael S. Tsirkin * 2. Redistributions in binary form must reproduce the above copyright 17*5878b136SMichael S. Tsirkin * notice, this list of conditions and the following disclaimer in the 18*5878b136SMichael S. Tsirkin * documentation and/or other materials provided with the distribution. 19*5878b136SMichael S. Tsirkin * 3. Neither the name of IBM nor the names of its contributors 20*5878b136SMichael S. Tsirkin * may be used to endorse or promote products derived from this software 21*5878b136SMichael S. Tsirkin * without specific prior written permission. 22*5878b136SMichael S. Tsirkin * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 23*5878b136SMichael S. Tsirkin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 24*5878b136SMichael S. Tsirkin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 25*5878b136SMichael S. Tsirkin * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 26*5878b136SMichael S. Tsirkin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 27*5878b136SMichael S. Tsirkin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 28*5878b136SMichael S. Tsirkin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 29*5878b136SMichael S. Tsirkin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 30*5878b136SMichael S. Tsirkin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 31*5878b136SMichael S. Tsirkin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 32*5878b136SMichael S. Tsirkin * SUCH DAMAGE. 33*5878b136SMichael S. Tsirkin */ 34*5878b136SMichael S. Tsirkin 35*5878b136SMichael S. Tsirkin #ifndef _LINUX_VIRTIO_MMIO_H 36*5878b136SMichael S. Tsirkin #define _LINUX_VIRTIO_MMIO_H 37*5878b136SMichael S. Tsirkin 38*5878b136SMichael S. Tsirkin /* 39*5878b136SMichael S. Tsirkin * Control registers 40*5878b136SMichael S. Tsirkin */ 41*5878b136SMichael S. Tsirkin 42*5878b136SMichael S. Tsirkin /* Magic value ("virt" string) - Read Only */ 43*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_MAGIC_VALUE 0x000 44*5878b136SMichael S. Tsirkin 45*5878b136SMichael S. Tsirkin /* Virtio device version - Read Only */ 46*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_VERSION 0x004 47*5878b136SMichael S. Tsirkin 48*5878b136SMichael S. Tsirkin /* Virtio device ID - Read Only */ 49*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_ID 0x008 50*5878b136SMichael S. Tsirkin 51*5878b136SMichael S. Tsirkin /* Virtio vendor ID - Read Only */ 52*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_VENDOR_ID 0x00c 53*5878b136SMichael S. Tsirkin 54*5878b136SMichael S. Tsirkin /* Bitmask of the features supported by the device (host) 55*5878b136SMichael S. Tsirkin * (32 bits per set) - Read Only */ 56*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_FEATURES 0x010 57*5878b136SMichael S. Tsirkin 58*5878b136SMichael S. Tsirkin /* Device (host) features set selector - Write Only */ 59*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_FEATURES_SEL 0x014 60*5878b136SMichael S. Tsirkin 61*5878b136SMichael S. Tsirkin /* Bitmask of features activated by the driver (guest) 62*5878b136SMichael S. Tsirkin * (32 bits per set) - Write Only */ 63*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DRIVER_FEATURES 0x020 64*5878b136SMichael S. Tsirkin 65*5878b136SMichael S. Tsirkin /* Activated features set selector - Write Only */ 66*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_DRIVER_FEATURES_SEL 0x024 67*5878b136SMichael S. Tsirkin 68*5878b136SMichael S. Tsirkin 69*5878b136SMichael S. Tsirkin #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */ 70*5878b136SMichael S. Tsirkin 71*5878b136SMichael S. Tsirkin /* Guest's memory page size in bytes - Write Only */ 72*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_GUEST_PAGE_SIZE 0x028 73*5878b136SMichael S. Tsirkin 74*5878b136SMichael S. Tsirkin #endif 75*5878b136SMichael S. Tsirkin 76*5878b136SMichael S. Tsirkin 77*5878b136SMichael S. Tsirkin /* Queue selector - Write Only */ 78*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_SEL 0x030 79*5878b136SMichael S. Tsirkin 80*5878b136SMichael S. Tsirkin /* Maximum size of the currently selected queue - Read Only */ 81*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NUM_MAX 0x034 82*5878b136SMichael S. Tsirkin 83*5878b136SMichael S. Tsirkin /* Queue size for the currently selected queue - Write Only */ 84*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NUM 0x038 85*5878b136SMichael S. Tsirkin 86*5878b136SMichael S. Tsirkin 87*5878b136SMichael S. Tsirkin #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */ 88*5878b136SMichael S. Tsirkin 89*5878b136SMichael S. Tsirkin /* Used Ring alignment for the currently selected queue - Write Only */ 90*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_ALIGN 0x03c 91*5878b136SMichael S. Tsirkin 92*5878b136SMichael S. Tsirkin /* Guest's PFN for the currently selected queue - Read Write */ 93*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_PFN 0x040 94*5878b136SMichael S. Tsirkin 95*5878b136SMichael S. Tsirkin #endif 96*5878b136SMichael S. Tsirkin 97*5878b136SMichael S. Tsirkin 98*5878b136SMichael S. Tsirkin /* Ready bit for the currently selected queue - Read Write */ 99*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_READY 0x044 100*5878b136SMichael S. Tsirkin 101*5878b136SMichael S. Tsirkin /* Queue notifier - Write Only */ 102*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NOTIFY 0x050 103*5878b136SMichael S. Tsirkin 104*5878b136SMichael S. Tsirkin /* Interrupt status - Read Only */ 105*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_INTERRUPT_STATUS 0x060 106*5878b136SMichael S. Tsirkin 107*5878b136SMichael S. Tsirkin /* Interrupt acknowledge - Write Only */ 108*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_INTERRUPT_ACK 0x064 109*5878b136SMichael S. Tsirkin 110*5878b136SMichael S. Tsirkin /* Device status register - Read Write */ 111*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_STATUS 0x070 112*5878b136SMichael S. Tsirkin 113*5878b136SMichael S. Tsirkin /* Selected queue's Descriptor Table address, 64 bits in two halves */ 114*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_DESC_LOW 0x080 115*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_DESC_HIGH 0x084 116*5878b136SMichael S. Tsirkin 117*5878b136SMichael S. Tsirkin /* Selected queue's Available Ring address, 64 bits in two halves */ 118*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_AVAIL_LOW 0x090 119*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_AVAIL_HIGH 0x094 120*5878b136SMichael S. Tsirkin 121*5878b136SMichael S. Tsirkin /* Selected queue's Used Ring address, 64 bits in two halves */ 122*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_USED_LOW 0x0a0 123*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_USED_HIGH 0x0a4 124*5878b136SMichael S. Tsirkin 125*5878b136SMichael S. Tsirkin /* Configuration atomicity value */ 126*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc 127*5878b136SMichael S. Tsirkin 128*5878b136SMichael S. Tsirkin /* The config space is defined by each driver as 129*5878b136SMichael S. Tsirkin * the per-driver configuration space - Read Write */ 130*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_CONFIG 0x100 131*5878b136SMichael S. Tsirkin 132*5878b136SMichael S. Tsirkin 133*5878b136SMichael S. Tsirkin 134*5878b136SMichael S. Tsirkin /* 135*5878b136SMichael S. Tsirkin * Interrupt flags (re: interrupt status & acknowledge registers) 136*5878b136SMichael S. Tsirkin */ 137*5878b136SMichael S. Tsirkin 138*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_INT_VRING (1 << 0) 139*5878b136SMichael S. Tsirkin #define VIRTIO_MMIO_INT_CONFIG (1 << 1) 140*5878b136SMichael S. Tsirkin 141*5878b136SMichael S. Tsirkin #endif 142