2014-07-21 00:41:40 -07:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2014 Travis Geiselbrecht
|
|
|
|
|
*
|
2019-07-05 17:22:23 -07:00
|
|
|
* Use of this source code is governed by a MIT-style
|
|
|
|
|
* license that can be found in the LICENSE file or at
|
|
|
|
|
* https://opensource.org/licenses/MIT
|
2014-07-21 00:41:40 -07:00
|
|
|
*/
|
|
|
|
|
#pragma once
|
|
|
|
|
|
2019-06-17 18:28:51 -07:00
|
|
|
#include <lk/compiler.h>
|
2014-07-21 00:41:40 -07:00
|
|
|
#include <stdint.h>
|
|
|
|
|
|
2024-03-20 00:26:58 -07:00
|
|
|
// V1 config
|
2014-07-21 00:41:40 -07:00
|
|
|
struct virtio_mmio_config {
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x00 */
|
|
|
|
|
uint32_t magic;
|
2016-02-14 12:24:01 -08:00
|
|
|
uint32_t version;
|
|
|
|
|
uint32_t device_id;
|
|
|
|
|
uint32_t vendor_id;
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x10 */
|
|
|
|
|
uint32_t host_features;
|
2016-02-14 12:24:01 -08:00
|
|
|
uint32_t host_features_sel;
|
|
|
|
|
uint32_t __reserved0[2];
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x20 */
|
|
|
|
|
uint32_t guest_features;
|
2016-02-14 12:24:01 -08:00
|
|
|
uint32_t guest_features_sel;
|
|
|
|
|
uint32_t guest_page_size;
|
|
|
|
|
uint32_t __reserved1[1];
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x30 */
|
|
|
|
|
uint32_t queue_sel;
|
2016-02-14 12:24:01 -08:00
|
|
|
uint32_t queue_num_max;
|
|
|
|
|
uint32_t queue_num;
|
|
|
|
|
uint32_t queue_align;
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x40 */
|
|
|
|
|
uint32_t queue_pfn;
|
2016-02-14 12:24:01 -08:00
|
|
|
uint32_t __reserved2[3];
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x50 */
|
|
|
|
|
uint32_t queue_notify;
|
2016-02-14 12:24:01 -08:00
|
|
|
uint32_t __reserved3[3];
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x60 */
|
|
|
|
|
uint32_t interrupt_status;
|
2016-02-14 12:24:01 -08:00
|
|
|
uint32_t interrupt_ack;
|
|
|
|
|
uint32_t __reserved4[2];
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x70 */
|
|
|
|
|
uint32_t status;
|
2016-02-14 12:24:01 -08:00
|
|
|
uint8_t __reserved5[0x8c];
|
2024-03-20 00:26:58 -07:00
|
|
|
/* 0x100 */
|
|
|
|
|
uint32_t config[0];
|
2014-07-21 00:41:40 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
STATIC_ASSERT(sizeof(struct virtio_mmio_config) == 0x100);
|
|
|
|
|
|
|
|
|
|
#define VIRTIO_MMIO_MAGIC 0x74726976 // 'virt'
|
2015-09-08 16:11:03 -07:00
|
|
|
|
|
|
|
|
#define VIRTIO_STATUS_ACKNOWLEDGE (1<<0)
|
|
|
|
|
#define VIRTIO_STATUS_DRIVER (1<<1)
|
|
|
|
|
#define VIRTIO_STATUS_DRIVER_OK (1<<2)
|
|
|
|
|
#define VIRTIO_STATUS_FEATURES_OK (1<<3)
|
|
|
|
|
#define VIRTIO_STATUS_DEVICE_NEEDS_RESET (1<<6)
|
|
|
|
|
#define VIRTIO_STATUS_FAILED (1<<7)
|