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_BUFFER_H
11#define VIRTIO_VIRTIO_BUFFER_H
12
13/**
14 * library internal representation of a buffer allocator
15 */
16struct virtio_buffer_allocator
17{
18    struct virtio_buffer *buffers;
19    struct virtio_buffer **buf_stack;   ///< array of virtio_buffers
20    uint16_t buf_size;                  ///< size of a buffer
21    uint16_t buf_count;                 ///< the number of buffers
22    uint16_t top;                       ///< pointer to the top slot
23    lpaddr_t offset;                    ///< the offset into the cap
24    struct capref cap;                  ///< frame capability backing this allocator
25    struct virtio_device *queue;        ///< the VirtIO device this allocator belongs to
26};
27
28/**
29 * \brief   assigns a buffer allocator to a virtqueue that it can be used as
30 *          buffers over the VirtIO channel.
31 *
32 * \param   bf   buffer allocator
33 * \param   vdev virtqueue the buffer allocator gets added to
34 */
35errval_t virtio_buffer_alloc_assing(struct virtio_buffer_allocator *bf,
36                                    struct virtio_device *vdev);
37
38
39
40#endif // VIRTIO_VIRTIO_BUFFER_H
41