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 LIB_DMA_MEM_UTILS_H
11#define LIB_DMA_MEM_UTILS_H
12
13/* forward declaration */
14struct dmem;
15struct iommu_client;
16
17/**
18 * \brief allocates and maps a memory region to be used for DMA purposes
19 *
20 * \param bytes minimum size of the memory region in bytes
21 * \param flags VREGION flags how the region gets mapped
22 * \param cl    IOMMU client if IOMMU is present
23 * \param mem   returns the mapping information
24 *
25 * \returns SYS_ERR_OK on success
26 *          errval on error
27 */
28errval_t dma_mem_alloc(size_t bytes,
29                       vregion_flags_t flags,
30                       struct iommu_client *cl,
31                       struct dmem *mem);
32
33/**
34 * \brief tries to free the allocated memory region
35 *
36 * \returns SYS_ERR_OK on success
37 *          errval on error
38 */
39errval_t dma_mem_free(struct dmem *mem);
40
41#endif /* LIB_DMA_MEM_UTILS_H */
42