1 /*
2 * (c) 2014 Alexander Warg <alexander.warg@kernkonzept.com>
3 *
4 * This file is part of TUD:OS and distributed under the terms of the
5 * GNU General Public License 2.
6 * Please see the COPYING-GPL-2 file for details.
7 *
8 * As a special exception, you may use this file as part of a free software
9 * library without restriction. Specifically, if other files instantiate
10 * templates or use macros or inline functions from this file, or you compile
11 * this file and link it with other files to produce an executable, this
12 * file does not by itself cause the resulting executable to be covered by
13 * the GNU General Public License. This exception does not however
14 * invalidate any other reasons why the executable file might be covered by
15 * the GNU General Public License.
16 */
17
18 #include <l4/re/c/dma_space.h>
19 #include <l4/re/dma_space>
20
21 L4_CV long
l4re_dma_space_map(l4re_dma_space_t dma,l4re_ds_t src,l4re_ds_offset_t offset,l4_size_t * size,unsigned long attrs,enum l4re_dma_space_direction dir,l4re_dma_space_dma_addr_t * dma_addr)22 l4re_dma_space_map(l4re_dma_space_t dma, l4re_ds_t src,
23 l4re_ds_offset_t offset,
24 l4_size_t * size, unsigned long attrs,
25 enum l4re_dma_space_direction dir,
26 l4re_dma_space_dma_addr_t *dma_addr) L4_NOTHROW
27 {
28 L4::Cap<L4Re::Dma_space> d(dma);
29 return d->map(L4::Ipc::Cap<L4Re::Dataspace>::from_ci(src),
30 offset, size,
31 L4Re::Dma_space::Attributes::from_raw(attrs),
32 L4Re::Dma_space::Direction(dir), dma_addr);
33 }
34
35
36 L4_CV long
l4re_dma_space_unmap(l4re_dma_space_t dma,l4re_dma_space_dma_addr_t dma_addr,l4_size_t size,unsigned long attrs,enum l4re_dma_space_direction dir)37 l4re_dma_space_unmap(l4re_dma_space_t dma, l4re_dma_space_dma_addr_t dma_addr,
38 l4_size_t size, unsigned long attrs,
39 enum l4re_dma_space_direction dir) L4_NOTHROW
40 {
41 L4::Cap<L4Re::Dma_space> d(dma);
42 return d->unmap(dma_addr, size,
43 L4Re::Dma_space::Attributes::from_raw(attrs),
44 L4Re::Dma_space::Direction(dir));
45 }
46
47 L4_CV long
l4re_dma_space_associate(l4re_dma_space_t dma,l4_cap_idx_t task,unsigned long attrs)48 l4re_dma_space_associate(l4re_dma_space_t dma, l4_cap_idx_t task,
49 unsigned long attrs) L4_NOTHROW
50 {
51 static_assert(L4RE_DMA_SPACE_COHERENT == 1 << L4Re::Dma_space::Coherent,
52 "enum mismatch");
53 static_assert(L4RE_DMA_SPACE_PHYS_SPACE == 1 << L4Re::Dma_space::Phys_space,
54 "enum mismatch");
55 L4::Cap<L4Re::Dma_space> d(dma);
56 return d->associate(L4::Ipc::Cap<L4::Task>::from_ci(task),
57 L4Re::Dma_space::Space_attribs::from_raw(attrs));
58 }
59
60 L4_CV long
l4re_dma_space_disassociate(l4re_dma_space_t dma)61 l4re_dma_space_disassociate(l4re_dma_space_t dma)
62 {
63 L4::Cap<L4Re::Dma_space> d(dma);
64 return d->disassociate();
65 }
66