1 /* 2 * Copyright (c) 2014 Travis Geiselbrecht 3 * 4 * Use of this source code is governed by a MIT-style 5 * license that can be found in the LICENSE file or at 6 * https://opensource.org/licenses/MIT 7 */ 8 #pragma once 9 10 #include <lk/compiler.h> 11 #include <stdint.h> 12 13 struct virtio_mmio_config { 14 /* 0x00 */ uint32_t magic; 15 uint32_t version; 16 uint32_t device_id; 17 uint32_t vendor_id; 18 /* 0x10 */ uint32_t host_features; 19 uint32_t host_features_sel; 20 uint32_t __reserved0[2]; 21 /* 0x20 */ uint32_t guest_features; 22 uint32_t guest_features_sel; 23 uint32_t guest_page_size; 24 uint32_t __reserved1[1]; 25 /* 0x30 */ uint32_t queue_sel; 26 uint32_t queue_num_max; 27 uint32_t queue_num; 28 uint32_t queue_align; 29 /* 0x40 */ uint32_t queue_pfn; 30 uint32_t __reserved2[3]; 31 /* 0x50 */ uint32_t queue_notify; 32 uint32_t __reserved3[3]; 33 /* 0x60 */ uint32_t interrupt_status; 34 uint32_t interrupt_ack; 35 uint32_t __reserved4[2]; 36 /* 0x70 */ uint32_t status; 37 uint8_t __reserved5[0x8c]; 38 /* 0x100 */ uint32_t config[0]; 39 }; 40 41 STATIC_ASSERT(sizeof(struct virtio_mmio_config) == 0x100); 42 43 #define VIRTIO_MMIO_MAGIC 0x74726976 // 'virt' 44 45 #define VIRTIO_STATUS_ACKNOWLEDGE (1<<0) 46 #define VIRTIO_STATUS_DRIVER (1<<1) 47 #define VIRTIO_STATUS_DRIVER_OK (1<<2) 48 #define VIRTIO_STATUS_FEATURES_OK (1<<3) 49 #define VIRTIO_STATUS_DEVICE_NEEDS_RESET (1<<6) 50 #define VIRTIO_STATUS_FAILED (1<<7) 51