151be7a9aSMichael S. Tsirkin /* 251be7a9aSMichael S. Tsirkin * Virtio platform device driver 351be7a9aSMichael S. Tsirkin * 451be7a9aSMichael S. Tsirkin * Copyright 2011, ARM Ltd. 551be7a9aSMichael S. Tsirkin * 651be7a9aSMichael S. Tsirkin * Based on Virtio PCI driver by Anthony Liguori, copyright IBM Corp. 2007 751be7a9aSMichael S. Tsirkin * 851be7a9aSMichael S. Tsirkin * This header is BSD licensed so anyone can use the definitions to implement 951be7a9aSMichael S. Tsirkin * compatible drivers/servers. 1051be7a9aSMichael S. Tsirkin * 1151be7a9aSMichael S. Tsirkin * Redistribution and use in source and binary forms, with or without 1251be7a9aSMichael S. Tsirkin * modification, are permitted provided that the following conditions 1351be7a9aSMichael S. Tsirkin * are met: 1451be7a9aSMichael S. Tsirkin * 1. Redistributions of source code must retain the above copyright 1551be7a9aSMichael S. Tsirkin * notice, this list of conditions and the following disclaimer. 1651be7a9aSMichael S. Tsirkin * 2. Redistributions in binary form must reproduce the above copyright 1751be7a9aSMichael S. Tsirkin * notice, this list of conditions and the following disclaimer in the 1851be7a9aSMichael S. Tsirkin * documentation and/or other materials provided with the distribution. 1951be7a9aSMichael S. Tsirkin * 3. Neither the name of IBM nor the names of its contributors 2051be7a9aSMichael S. Tsirkin * may be used to endorse or promote products derived from this software 2151be7a9aSMichael S. Tsirkin * without specific prior written permission. 2251be7a9aSMichael S. Tsirkin * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS IS'' AND 2351be7a9aSMichael S. Tsirkin * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2451be7a9aSMichael S. Tsirkin * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2551be7a9aSMichael S. Tsirkin * ARE DISCLAIMED. IN NO EVENT SHALL IBM OR CONTRIBUTORS BE LIABLE 2651be7a9aSMichael S. Tsirkin * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 2751be7a9aSMichael S. Tsirkin * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 2851be7a9aSMichael S. Tsirkin * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 2951be7a9aSMichael S. Tsirkin * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3051be7a9aSMichael S. Tsirkin * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3151be7a9aSMichael S. Tsirkin * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3251be7a9aSMichael S. Tsirkin * SUCH DAMAGE. 3351be7a9aSMichael S. Tsirkin */ 3451be7a9aSMichael S. Tsirkin 3551be7a9aSMichael S. Tsirkin #ifndef _LINUX_VIRTIO_MMIO_H 3651be7a9aSMichael S. Tsirkin #define _LINUX_VIRTIO_MMIO_H 3751be7a9aSMichael S. Tsirkin 3851be7a9aSMichael S. Tsirkin /* 3951be7a9aSMichael S. Tsirkin * Control registers 4051be7a9aSMichael S. Tsirkin */ 4151be7a9aSMichael S. Tsirkin 4251be7a9aSMichael S. Tsirkin /* Magic value ("virt" string) - Read Only */ 4351be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_MAGIC_VALUE 0x000 4451be7a9aSMichael S. Tsirkin 4551be7a9aSMichael S. Tsirkin /* Virtio device version - Read Only */ 4651be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_VERSION 0x004 4751be7a9aSMichael S. Tsirkin 4851be7a9aSMichael S. Tsirkin /* Virtio device ID - Read Only */ 4951be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_ID 0x008 5051be7a9aSMichael S. Tsirkin 5151be7a9aSMichael S. Tsirkin /* Virtio vendor ID - Read Only */ 5251be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_VENDOR_ID 0x00c 5351be7a9aSMichael S. Tsirkin 5451be7a9aSMichael S. Tsirkin /* Bitmask of the features supported by the device (host) 5551be7a9aSMichael S. Tsirkin * (32 bits per set) - Read Only */ 5651be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_FEATURES 0x010 5751be7a9aSMichael S. Tsirkin 5851be7a9aSMichael S. Tsirkin /* Device (host) features set selector - Write Only */ 5951be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_DEVICE_FEATURES_SEL 0x014 6051be7a9aSMichael S. Tsirkin 6151be7a9aSMichael S. Tsirkin /* Bitmask of features activated by the driver (guest) 6251be7a9aSMichael S. Tsirkin * (32 bits per set) - Write Only */ 6351be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_DRIVER_FEATURES 0x020 6451be7a9aSMichael S. Tsirkin 6551be7a9aSMichael S. Tsirkin /* Activated features set selector - Write Only */ 6651be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_DRIVER_FEATURES_SEL 0x024 6751be7a9aSMichael S. Tsirkin 6851be7a9aSMichael S. Tsirkin 6951be7a9aSMichael S. Tsirkin #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */ 7051be7a9aSMichael S. Tsirkin 7151be7a9aSMichael S. Tsirkin /* Guest's memory page size in bytes - Write Only */ 7251be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_GUEST_PAGE_SIZE 0x028 7351be7a9aSMichael S. Tsirkin 7451be7a9aSMichael S. Tsirkin #endif 7551be7a9aSMichael S. Tsirkin 7651be7a9aSMichael S. Tsirkin 7751be7a9aSMichael S. Tsirkin /* Queue selector - Write Only */ 7851be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_SEL 0x030 7951be7a9aSMichael S. Tsirkin 8051be7a9aSMichael S. Tsirkin /* Maximum size of the currently selected queue - Read Only */ 8151be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NUM_MAX 0x034 8251be7a9aSMichael S. Tsirkin 8351be7a9aSMichael S. Tsirkin /* Queue size for the currently selected queue - Write Only */ 8451be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NUM 0x038 8551be7a9aSMichael S. Tsirkin 8651be7a9aSMichael S. Tsirkin 8751be7a9aSMichael S. Tsirkin #ifndef VIRTIO_MMIO_NO_LEGACY /* LEGACY DEVICES ONLY! */ 8851be7a9aSMichael S. Tsirkin 8951be7a9aSMichael S. Tsirkin /* Used Ring alignment for the currently selected queue - Write Only */ 9051be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_ALIGN 0x03c 9151be7a9aSMichael S. Tsirkin 9251be7a9aSMichael S. Tsirkin /* Guest's PFN for the currently selected queue - Read Write */ 9351be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_PFN 0x040 9451be7a9aSMichael S. Tsirkin 9551be7a9aSMichael S. Tsirkin #endif 9651be7a9aSMichael S. Tsirkin 9751be7a9aSMichael S. Tsirkin 9851be7a9aSMichael S. Tsirkin /* Ready bit for the currently selected queue - Read Write */ 9951be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_READY 0x044 10051be7a9aSMichael S. Tsirkin 10151be7a9aSMichael S. Tsirkin /* Queue notifier - Write Only */ 10251be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_NOTIFY 0x050 10351be7a9aSMichael S. Tsirkin 10451be7a9aSMichael S. Tsirkin /* Interrupt status - Read Only */ 10551be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_INTERRUPT_STATUS 0x060 10651be7a9aSMichael S. Tsirkin 10751be7a9aSMichael S. Tsirkin /* Interrupt acknowledge - Write Only */ 10851be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_INTERRUPT_ACK 0x064 10951be7a9aSMichael S. Tsirkin 11051be7a9aSMichael S. Tsirkin /* Device status register - Read Write */ 11151be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_STATUS 0x070 11251be7a9aSMichael S. Tsirkin 11351be7a9aSMichael S. Tsirkin /* Selected queue's Descriptor Table address, 64 bits in two halves */ 11451be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_DESC_LOW 0x080 11551be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_DESC_HIGH 0x084 11651be7a9aSMichael S. Tsirkin 11751be7a9aSMichael S. Tsirkin /* Selected queue's Available Ring address, 64 bits in two halves */ 11851be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_AVAIL_LOW 0x090 11951be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_AVAIL_HIGH 0x094 12051be7a9aSMichael S. Tsirkin 12151be7a9aSMichael S. Tsirkin /* Selected queue's Used Ring address, 64 bits in two halves */ 12251be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_USED_LOW 0x0a0 12351be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_QUEUE_USED_HIGH 0x0a4 12451be7a9aSMichael S. Tsirkin 125*38e89548SSebastien Boeuf /* Shared memory region id */ 126*38e89548SSebastien Boeuf #define VIRTIO_MMIO_SHM_SEL 0x0ac 127*38e89548SSebastien Boeuf 128*38e89548SSebastien Boeuf /* Shared memory region length, 64 bits in two halves */ 129*38e89548SSebastien Boeuf #define VIRTIO_MMIO_SHM_LEN_LOW 0x0b0 130*38e89548SSebastien Boeuf #define VIRTIO_MMIO_SHM_LEN_HIGH 0x0b4 131*38e89548SSebastien Boeuf 132*38e89548SSebastien Boeuf /* Shared memory region base address, 64 bits in two halves */ 133*38e89548SSebastien Boeuf #define VIRTIO_MMIO_SHM_BASE_LOW 0x0b8 134*38e89548SSebastien Boeuf #define VIRTIO_MMIO_SHM_BASE_HIGH 0x0bc 135*38e89548SSebastien Boeuf 13651be7a9aSMichael S. Tsirkin /* Configuration atomicity value */ 13751be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_CONFIG_GENERATION 0x0fc 13851be7a9aSMichael S. Tsirkin 13951be7a9aSMichael S. Tsirkin /* The config space is defined by each driver as 14051be7a9aSMichael S. Tsirkin * the per-driver configuration space - Read Write */ 14151be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_CONFIG 0x100 14251be7a9aSMichael S. Tsirkin 14351be7a9aSMichael S. Tsirkin 14451be7a9aSMichael S. Tsirkin 14551be7a9aSMichael S. Tsirkin /* 14651be7a9aSMichael S. Tsirkin * Interrupt flags (re: interrupt status & acknowledge registers) 14751be7a9aSMichael S. Tsirkin */ 14851be7a9aSMichael S. Tsirkin 14951be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_INT_VRING (1 << 0) 15051be7a9aSMichael S. Tsirkin #define VIRTIO_MMIO_INT_CONFIG (1 << 1) 15151be7a9aSMichael S. Tsirkin 15251be7a9aSMichael S. Tsirkin #endif 153