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