3 * \brief Region map client stub implementation
6 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
7 * Alexander Warg <warg@os.inf.tu-dresden.de>
8 * economic rights: Technische Universität Dresden (Germany)
10 * This file is part of TUD:OS and distributed under the terms of the
11 * GNU General Public License 2.
12 * Please see the COPYING-GPL-2 file for details.
14 * As a special exception, you may use this file as part of a free software
15 * library without restriction. Specifically, if other files instantiate
16 * templates or use macros or inline functions from this file, or you compile
17 * this file and link it with other files to produce an executable, this
18 * file does not by itself cause the resulting executable to be covered by
19 * the GNU General Public License. This exception does not however
20 * invalidate any other reasons why the executable file might be covered by
21 * the GNU General Public License.
24 #include <l4/re/rm-sys.h>
25 #include <l4/re/dataspace>
26 #include <l4/re/protocols>
28 #include <l4/cxx/ipc_helper>
29 #include <l4/cxx/ipc_stream>
31 #include <l4/sys/task>
32 #include <l4/sys/err.h>
41 Rm::reserve_area(l4_addr_t *start, unsigned long size, unsigned flags,
42 unsigned char align) const throw()
44 L4::Ipc_iostream io(l4_utcb());
45 io << Opcode(Rm_::Attach_area) << *start << size << flags << align;
46 long err = l4_error(io.call(cap(), L4Re::Protocol::Rm));
47 if (EXPECT_FALSE(err < 0))
55 Rm::free_area(l4_addr_t addr) const throw()
57 L4::Ipc_iostream io(l4_utcb());
58 io << Opcode(Rm_::Detach_area) << addr;
59 return l4_error(io.call(cap(), L4Re::Protocol::Rm));
63 Rm::attach(l4_addr_t *start, unsigned long size, unsigned long flags,
64 L4::Cap<Dataspace> mem, l4_addr_t offs,
65 unsigned char align) const throw()
67 L4::Ipc_iostream io(l4_utcb());
68 io << Opcode(Rm_::Attach) << l4_addr_t(*start) << size << flags
71 if (!(flags & Reserved))
72 io << mem.cap() << mem;
74 long err = l4_error(io.call(cap(), L4Re::Protocol::Rm));
75 if (EXPECT_FALSE(err < 0))
78 io >> *reinterpret_cast<l4_addr_t*>(start);
80 if (flags & Eager_map)
82 unsigned long fl = (flags & Read_only)
85 err = mem->map_region(offs, fl, *start, *start + size);
91 Rm::_detach(l4_addr_t addr, unsigned long size, L4::Cap<Dataspace> *mem,
92 L4::Cap<L4::Task> task, unsigned flags) const throw()
94 L4::Ipc_iostream io(l4_utcb());
95 io << Opcode(Rm_::Detach) << addr << size << flags;
96 long err = l4_error(io.call(cap(), L4Re::Protocol::Rm));
97 if (EXPECT_FALSE(err < 0))
102 io >> start >> rsize;
105 io >> *reinterpret_cast<l4_cap_idx_t*>(mem);
107 if (!task.is_valid())
110 for (unsigned long p = 0; p < rsize; p += L4_PAGESIZE)
112 task->unmap(l4_fpage(start + p, L4_LOG2_PAGESIZE, L4_FPAGE_RWX),
121 Rm::find(l4_addr_t *addr, unsigned long *size, unsigned long *offset,
122 unsigned *flags, L4::Cap<Dataspace> *m) throw()
124 L4::Ipc_iostream io(l4_utcb());
125 io << Opcode(Rm_::Find) << *addr << *size;
126 long err = l4_error(io.call(cap(), L4Re::Protocol::Rm));
127 if (EXPECT_FALSE(err < 0))
131 io >> *addr >> *size >> *flags >> *offset >> c;
132 *m = L4::Cap<Dataspace>(c);