]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re_c/lib/src/rm.cc
update
[l4.git] / l4 / pkg / l4re_c / lib / src / rm.cc
1 /*
2  * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
3  *               Alexander Warg <warg@os.inf.tu-dresden.de>
4  *     economic rights: Technische Universität Dresden (Germany)
5  *
6  * This file is part of TUD:OS and distributed under the terms of the
7  * GNU General Public License 2.
8  * Please see the COPYING-GPL-2 file for details.
9  *
10  * As a special exception, you may use this file as part of a free software
11  * library without restriction.  Specifically, if other files instantiate
12  * templates or use macros or inline functions from this file, or you compile
13  * this file and link it with other files to produce an executable, this
14  * file does not by itself cause the resulting executable to be covered by
15  * the GNU General Public License.  This exception does not however
16  * invalidate any other reasons why the executable file might be covered by
17  * the GNU General Public License.
18  */
19
20 #include <l4/sys/err.h>
21 #include <l4/re/rm>
22 #include <l4/re/env>
23 #include <l4/re/dataspace>
24 #include <l4/re/debug>
25
26 #include <l4/re/c/rm.h>
27 #include <l4/re/c/dataspace.h>
28
29 int
30 l4re_rm_reserve_area_srv(l4_cap_idx_t rm, l4_addr_t *start, unsigned long size,
31                          unsigned flags, unsigned char align) L4_NOTHROW
32 {
33   L4::Cap<L4Re::Rm> x(rm);
34   return x->reserve_area(start, size, flags, align);
35 }
36
37 int
38 l4re_rm_free_area_srv(l4_cap_idx_t rm, l4_addr_t addr) L4_NOTHROW
39 {
40   L4::Cap<L4Re::Rm> x(rm);
41   return x->free_area(addr);
42 }
43
44 int
45 l4re_rm_attach_srv(l4_cap_idx_t rm, void **start, unsigned long size,
46                    unsigned long flags, l4re_ds_t const mem, l4_addr_t offs,
47                    unsigned char align) L4_NOTHROW
48 {
49   L4::Cap<L4Re::Rm> x(rm);
50   L4::Cap<L4Re::Dataspace> _mem(mem);
51   return x->attach(start, size, flags, _mem, offs, align);
52 }
53
54
55 int
56 l4re_rm_detach_srv(l4_cap_idx_t rm, l4_addr_t addr, l4re_ds_t *ds,
57                    l4_cap_idx_t task) L4_NOTHROW
58 {
59   L4::Cap<L4Re::Rm> x(rm);
60   L4::Cap<L4::Task> t(task);
61   L4::Cap<L4Re::Dataspace> d;
62   int r = x->detach(addr, &d, t);
63   if (ds)
64     *ds = d.cap();
65   return r;
66 }
67
68
69 int
70 l4re_rm_find_srv(l4_cap_idx_t rm, l4_addr_t *addr,
71                  unsigned long *size, l4_addr_t *offset,
72                  unsigned *flags, l4_cap_idx_t *m) L4_NOTHROW
73 {
74   L4::Cap<L4Re::Rm> x(rm);
75   L4::Cap<L4Re::Dataspace> mm;
76   int r = x->find(addr, size, offset, flags, &mm);
77   *m = mm.cap();
78   return r;
79 }
80
81 void
82 l4re_rm_show_lists_srv(l4_cap_idx_t rm) L4_NOTHROW
83 {
84   L4::Cap<L4Re::Debug_obj> d(rm);
85   d->debug(0); // XXX: use enum
86 }