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 25bca964bcSSergio Lopez #include "hw/virtio/virtio-bus.h" 26*db1015e9SEduardo Habkost #include "qom/object.h" 27bca964bcSSergio Lopez 28bca964bcSSergio Lopez /* QOM macros */ 29bca964bcSSergio Lopez /* virtio-mmio-bus */ 30bca964bcSSergio Lopez #define TYPE_VIRTIO_MMIO_BUS "virtio-mmio-bus" 31bca964bcSSergio Lopez #define VIRTIO_MMIO_BUS(obj) \ 32bca964bcSSergio Lopez OBJECT_CHECK(VirtioBusState, (obj), TYPE_VIRTIO_MMIO_BUS) 33bca964bcSSergio Lopez #define VIRTIO_MMIO_BUS_GET_CLASS(obj) \ 34bca964bcSSergio Lopez OBJECT_GET_CLASS(VirtioBusClass, (obj), TYPE_VIRTIO_MMIO_BUS) 35bca964bcSSergio Lopez #define VIRTIO_MMIO_BUS_CLASS(klass) \ 36bca964bcSSergio Lopez OBJECT_CLASS_CHECK(VirtioBusClass, (klass), TYPE_VIRTIO_MMIO_BUS) 37bca964bcSSergio Lopez 38bca964bcSSergio Lopez /* virtio-mmio */ 39bca964bcSSergio Lopez #define TYPE_VIRTIO_MMIO "virtio-mmio" 40*db1015e9SEduardo Habkost typedef struct VirtIOMMIOProxy VirtIOMMIOProxy; 41bca964bcSSergio Lopez #define VIRTIO_MMIO(obj) \ 42bca964bcSSergio Lopez OBJECT_CHECK(VirtIOMMIOProxy, (obj), TYPE_VIRTIO_MMIO) 43bca964bcSSergio Lopez 44bca964bcSSergio Lopez #define VIRT_MAGIC 0x74726976 /* 'virt' */ 45bca964bcSSergio Lopez #define VIRT_VERSION 2 46bca964bcSSergio Lopez #define VIRT_VERSION_LEGACY 1 47bca964bcSSergio Lopez #define VIRT_VENDOR 0x554D4551 /* 'QEMU' */ 48bca964bcSSergio Lopez 49bca964bcSSergio Lopez typedef struct VirtIOMMIOQueue { 50bca964bcSSergio Lopez uint16_t num; 51bca964bcSSergio Lopez bool enabled; 52bca964bcSSergio Lopez uint32_t desc[2]; 53bca964bcSSergio Lopez uint32_t avail[2]; 54bca964bcSSergio Lopez uint32_t used[2]; 55bca964bcSSergio Lopez } VirtIOMMIOQueue; 56bca964bcSSergio Lopez 57*db1015e9SEduardo Habkost struct VirtIOMMIOProxy { 58bca964bcSSergio Lopez /* Generic */ 59bca964bcSSergio Lopez SysBusDevice parent_obj; 60bca964bcSSergio Lopez MemoryRegion iomem; 61bca964bcSSergio Lopez qemu_irq irq; 62bca964bcSSergio Lopez bool legacy; 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]; 73*db1015e9SEduardo Habkost }; 74bca964bcSSergio Lopez 75bca964bcSSergio Lopez #endif 76