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 DMA_RING_INTERNAL_H
11#define DMA_RING_INTERNAL_H
12
13#include <dma/dma_ring.h>
14
15/// maximum ring size in bits
16#define DMA_RING_SIZE_MAX 15
17
18
19/*
20 * ----------------------------------------------------------------------------
21 * Ring Manipulation
22 * ----------------------------------------------------------------------------
23 */
24
25/**
26 * \brief gets the next descriptor based on the head pointer and increments the
27 *        head pointer
28 *
29 * \param ring the DMA ring
30 *
31 * \returns pointer to a DMA descriptor
32 */
33struct dma_descriptor *dma_ring_get_next_desc(struct dma_ring *ring);
34
35/**
36 * \brief gets the next descriptor based on the tail pointer and increases the
37 *        tail pointer index
38 *
39 * \param ring the DMA ring
40 *
41 * \returns pointer to a DMA descriptor
42 */
43struct dma_descriptor *dma_ring_get_tail_desc(struct dma_ring *ring);
44
45/**
46 * \brief submits the pending descriptors to the hardware
47 *
48 * \param ring DMA ring to submit the pending descriptors
49 *
50 * \returns the current head of the descriptors
51 */
52uint16_t dma_ring_submit_pending(struct dma_ring *ring);
53
54/**
55 * \brief obtains the physical address of the descriptor chain
56 *        (pending descriptors)
57 *
58 * \param ring the DMA ring
59 *
60 * \returns physical address of the pending descriptor chain
61 */
62lpaddr_t dma_ring_get_base_addr(struct dma_ring *ring);
63
64/**
65 * \brief obtains the physical address of the descriptor ring
66 *
67 * \param ring the DMA ring
68 *
69 * \returns physical address of the pending descriptor chain
70 */
71lpaddr_t dma_ring_get_chain_addr(struct dma_ring *ring);
72
73#endif /* DMA_RING_INTERNAL_H */
74