]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re/lib/src/video/goos.cc
update
[l4.git] / l4 / pkg / l4re / lib / src / video / goos.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/re/video/goos>
21 #include <l4/re/video/goos-sys.h>
22
23 #include <l4/re/dataspace>
24 #include <l4/re/protocols>
25
26 #include <l4/cxx/ipc_helper>
27 #include <l4/cxx/ipc_stream>
28
29 #include <l4/sys/err.h>
30
31
32 namespace L4Re { namespace Video {
33
34 using L4::Opcode;
35
36 int
37 Goos::info(Info *info) const throw()
38 {
39   L4::Ipc_iostream io(l4_utcb());
40   io << Opcode(Goos_::Info);
41   long err = l4_error(io.call(cap(), L4Re::Protocol::Goos));
42   if (EXPECT_FALSE(err < 0))
43     return err;
44
45   io.get(*info);
46   return err;
47 }
48
49 int
50 Goos::get_static_buffer(unsigned idx, L4::Cap<Dataspace> ds) const throw()
51 {
52   L4::Ipc_iostream io(l4_utcb());
53   io << Opcode(Goos_::Get_buffer) << idx;
54   io << L4::Small_buf(ds.cap());
55   return l4_error(io.call(cap(), L4Re::Protocol::Goos));
56 }
57
58 int
59 Goos::create_buffer(unsigned long size, L4::Cap<Dataspace> ds) const throw()
60 {
61   L4::Ipc_iostream io(l4_utcb());
62   io << Opcode(Goos_::Create_buffer) << size;
63   io << L4::Small_buf(ds.cap());
64   return l4_error(io.call(cap(), L4Re::Protocol::Goos));
65 }
66
67 int
68 Goos::delete_buffer(unsigned idx) const throw()
69 {
70   L4::Ipc_iostream io(l4_utcb());
71   io << Opcode(Goos_::Delete_buffer) << idx;
72   return l4_error(io.call(cap(), L4Re::Protocol::Goos));
73 }
74
75 int
76 Goos::create_view(View *view) const throw()
77 {
78   L4::Ipc_iostream io(l4_utcb());
79   io << Opcode(Goos_::Create_view);
80   int err = l4_error(io.call(cap(), L4Re::Protocol::Goos));
81   if (err < 0)
82     return err;
83
84   *view = View(cap(), err);
85   return err;
86 }
87
88 int
89 Goos::delete_view(View const &v) const throw()
90 {
91   L4::Ipc_iostream io(l4_utcb());
92   io << Opcode(Goos_::Delete_view) << v._view_idx;
93   return l4_error(io.call(cap(), L4Re::Protocol::Goos));
94 }
95
96 }}