3 * \brief Region map client stub implementation
6 * (c) 2008-2009 Technische Universität Dresden
7 * This file is part of TUD:OS and distributed under the terms of the
8 * GNU General Public License 2.
9 * Please see the COPYING-GPL-2 file for details.
11 * As a special exception, you may use this file as part of a free software
12 * library without restriction. Specifically, if other files instantiate
13 * templates or use macros or inline functions from this file, or you compile
14 * this file and link it with other files to produce an executable, this
15 * file does not by itself cause the resulting executable to be covered by
16 * the GNU General Public License. This exception does not however
17 * invalidate any other reasons why the executable file might be covered by
18 * the GNU General Public License.
21 #include <l4/re/rm-sys.h>
22 #include <l4/re/dataspace>
23 #include <l4/re/protocols>
25 #include <l4/cxx/ipc_helper>
26 #include <l4/cxx/ipc_stream>
28 #include <l4/sys/task>
29 #include <l4/sys/err.h>
38 Rm::reserve_area(l4_addr_t *start, unsigned long size, unsigned flags,
39 unsigned char align) const throw()
41 L4::Ipc_iostream io(l4_utcb());
42 io << Opcode(Rm_::Attach_area) << *start << size << flags << align;
43 long err = l4_error(io.call(cap(), L4Re::Protocol::Rm));
44 if (EXPECT_FALSE(err < 0))
52 Rm::free_area(l4_addr_t addr) const throw()
54 L4::Ipc_iostream io(l4_utcb());
55 io << Opcode(Rm_::Detach_area) << addr;
56 return l4_error(io.call(cap(), L4Re::Protocol::Rm));
60 Rm::attach(l4_addr_t *start, unsigned long size, unsigned long flags,
61 L4::Cap<Dataspace> mem, l4_addr_t offs,
62 unsigned char align) const throw()
64 L4::Ipc_iostream io(l4_utcb());
65 io << Opcode(Rm_::Attach) << l4_addr_t(*start) << size << flags
68 if (!(flags & Reserved))
69 io << mem.cap() << mem;
71 long err = l4_error(io.call(cap(), L4Re::Protocol::Rm));
72 if (EXPECT_FALSE(err < 0))
75 io >> *reinterpret_cast<l4_addr_t*>(start);
77 if (flags & Eager_map)
79 unsigned long fl = (flags & Read_only)
82 err = mem->map_region(offs, fl, *start, *start + size);
88 Rm::_detach(l4_addr_t addr, unsigned long size, L4::Cap<Dataspace> *mem,
89 L4::Cap<L4::Task> task, unsigned flags) const throw()
91 L4::Ipc_iostream io(l4_utcb());
92 io << Opcode(Rm_::Detach) << addr << size << flags;
93 long err = l4_error(io.call(cap(), L4Re::Protocol::Rm));
94 if (EXPECT_FALSE(err < 0))
102 io >> *reinterpret_cast<l4_cap_idx_t*>(mem);
104 if (!task.is_valid())
107 for (unsigned long p = 0; p < rsize; p += L4_PAGESIZE)
109 task->unmap(l4_fpage(start + p, L4_LOG2_PAGESIZE, L4_FPAGE_RWX),
118 Rm::find(l4_addr_t *addr, unsigned long *size, unsigned long *offset,
119 unsigned *flags, L4::Cap<Dataspace> *m) throw()
121 L4::Ipc_iostream io(l4_utcb());
122 io << Opcode(Rm_::Find) << *addr << *size;
123 long err = l4_error(io.call(cap(), L4Re::Protocol::Rm));
124 if (EXPECT_FALSE(err < 0))
128 io >> *addr >> *size >> *flags >> *offset >> c;
129 *m = L4::Cap<Dataspace>(c);