3 * (c) 2008-2009 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
4 * Alexander Warg <warg@os.inf.tu-dresden.de>
5 * economic rights: Technische Universität Dresden (Germany)
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.
23 #include <l4/re/event_enums.h>
24 #include <l4/re/event>
25 #include <l4/re/event-sys.h>
26 #include <l4/re/util/icu_svr>
28 namespace L4Re { namespace Util {
30 template< typename SVR >
31 class Event_svr : public Icu_cap_array_svr<SVR>
34 typedef Icu_cap_array_svr<SVR> Icu_svr;
37 L4::Cap<L4Re::Dataspace> _ds;
38 typename Icu_svr::Irq _irq;
41 Event_svr() : Icu_svr(1, &_irq) {}
42 int dispatch(l4_umword_t obj, L4::Ipc_iostream &ios);
43 int get_num_streams() const { return 0; }
44 int get_stream_info(int, L4Re::Event_stream_info *)
45 { return -L4_EINVAL; }
46 int get_stream_info_for_id(l4_umword_t, L4Re::Event_stream_info *)
47 { return -L4_EINVAL; }
48 int get_axis_info(l4_umword_t, unsigned /*naxes*/, unsigned * /*axes*/,
49 L4Re::Event_absinfo *infos)
50 { return -L4_EINVAL; }
53 template<typename SVR>
56 Event_svr<SVR>::dispatch(l4_umword_t obj, L4::Ipc_iostream &ios)
61 if (tag.label() == L4_PROTO_IRQ)
62 return Icu_svr::dispatch(obj, ios);
63 else if (tag.label() != L4Re::Protocol::Event)
70 case L4Re::Event_::Get:
73 case L4Re::Event_::Get_num_streams:
74 ios << (l4_umword_t)static_cast<SVR*>(this)->get_num_streams();
76 case L4Re::Event_::Get_stream_info:
81 int r = static_cast<SVR*>(this)->get_stream_info(idx, &si);
85 case L4Re::Event_::Get_stream_info_for_id:
87 l4_umword_t stream_id;
90 int r = static_cast<SVR*>(this)->get_stream_info_for_id(stream_id, &si);
94 case L4Re::Event_::Get_axis_info:
96 l4_umword_t stream_id;
97 long unsigned naxes = L4RE_ABS_MAX;
98 unsigned axes[L4RE_ABS_MAX];
99 ios >> stream_id >> L4::Ipc::buf_cp_in(axes, naxes);
101 Event_absinfo infos[naxes];
102 int r = static_cast<SVR*>(this)->get_axis_info(stream_id, naxes, axes, infos);
106 ios << L4::Ipc::buf_cp_out(infos, naxes);