]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/l4re/lib/src/event.cc
update
[l4.git] / l4 / pkg / l4re / lib / src / event.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 #include <l4/re/event>
20 #include <l4/re/event-sys.h>
21 #include <l4/re/dataspace>
22 #include <l4/re/protocols>
23
24 #include <l4/sys/err.h>
25
26 #include <l4/cxx/ipc_stream>
27
28 namespace L4Re
29 {
30
31 using L4::Opcode;
32
33 long
34 Event::get_buffer(L4::Cap<Dataspace> ds) const throw()
35 {
36   L4::Ipc::Iostream io(l4_utcb());
37   io << Opcode(Event_::Get);
38   io << L4::Ipc::Small_buf(ds.cap());
39   return l4_error(io.call(cap(), L4Re::Protocol::Event));
40 }
41
42 long
43 Event::get_num_streams() const throw()
44 {
45   L4::Ipc::Iostream io(l4_utcb());
46   io << Opcode(Event_::Get_num_streams);
47   return l4_error(io.call(cap(), L4Re::Protocol::Event));
48 }
49
50 long
51 Event::get_stream_info(int idx, Event_stream_info *info) const throw()
52 {
53   L4::Ipc::Iostream io(l4_utcb());
54   io << Opcode(Event_::Get_stream_info) << idx;
55   long res = l4_error(io.call(cap(), L4Re::Protocol::Event));
56   if (res < 0)
57     return res;
58
59   io.get(*info);
60   return 0;
61 }
62
63 long
64 Event::get_stream_info_for_id(l4_umword_t id, Event_stream_info *info) const throw()
65 {
66   L4::Ipc::Iostream io(l4_utcb());
67   io << Opcode(Event_::Get_stream_info_for_id) << id;
68   long res = l4_error(io.call(cap(), L4Re::Protocol::Event));
69   if (res < 0)
70     return res;
71
72   io.get(*info);
73   return 0;
74 }
75
76 long
77 Event::get_axis_info(l4_umword_t id, unsigned naxes, unsigned *axis,
78                      Event_absinfo *info) const throw()
79 {
80   L4::Ipc::Iostream io(l4_utcb());
81   io << Opcode(Event_::Get_axis_info) << id << L4::Ipc::buf_cp_out(axis, naxes);
82   long res = l4_error(io.call(cap(), L4Re::Protocol::Event));
83   if (res < 0)
84     return res;
85
86   long unsigned a = naxes;
87   io >> L4::Ipc::buf_cp_in(info, a);
88   return 0;
89 }
90
91 long
92 Event::get_stream_state_for_id(l4_umword_t stream_id, Event_stream_state *state) const throw()
93 {
94   L4::Ipc::Iostream io(l4_utcb());
95   io << Opcode(Event_::Get_stream_state_for_id) << stream_id;
96   long res = l4_error(io.call(cap(), L4Re::Protocol::Event));
97   if (res < 0)
98     return res;
99
100   io.get(*state);
101   return 0;
102 }
103
104 }