1/* 2 * Copyright (c) 2014 ETH Zurich. 3 * All rights reserved. 4 * 5 * This file is distributed under the terms in the attached LICENSE file. 6 * If you do not find this file, copies can be found by writing to: 7 * ETH Zurich D-INFK, Universitaetsstrasse 6, CH-8092 Zurich. Attn: Systems Group. 8 */ 9 10#ifndef VIRTIO_VIRTIO_MMIO_H 11#define VIRTIO_VIRTIO_MMIO_H 12 13#include <virtio/virtio_device.h> 14 15#include <dev/virtio/virtio_mmio_dev.h> 16 17#define VIRTIO_MMIO_DEVICE_SIZE 0x100 18 19struct virtio_device_mmio 20{ 21 struct virtio_device dev; 22 virtio_mmio_t regs; ///< mackerel device registers 23 void *dev_base; ///< mapped virtual base address of this device 24 size_t dev_size; ///< size of the mapped device region 25#ifdef __VIRTIO_HOST__ 26 struct mmio_dev_regs { 27 uint8_t status; 28 uint8_t dev_feature_sel : 4; 29 uint8_t driv_feature_sel : 4; 30 uint32_t driv_features[2]; 31 uint16_t queue_sel; 32 }dev_reg; 33#endif 34}; 35 36 37/** 38 * \brief initializes and allocates a VirtIO device structure for the MMIO backend 39 * 40 * \param dev returns a pointer to the newly allocated device structure 41 * \param info initialization parameters 42 * 43 * \returns SYS_ERR_OK on success 44 */ 45errval_t virtio_device_mmio_init(struct virtio_device **dev, 46 struct virtio_device_setup *info); 47 48/** 49 * \brief initializes a VirtIO device on the host side using the MMIO transpot 50 * 51 * \param dev returns a pointer to the newly allocated device structure 52 * \param info initialization parameters 53 * 54 * \returns SYS_ERR_OK on success 55 */ 56errval_t virtio_device_mmio_init_host(struct virtio_device **dev, 57 struct virtio_device_setup *setup); 58 59#endif // VIRTIO_VIRTIO_MMIO_H 60