]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/io/server/src/server.cc
update
[l4.git] / l4 / pkg / io / server / src / server.cc
1 /*
2  * (c) 2010 Alexander Warg <warg@os.inf.tu-dresden.de>
3  *     economic rights: Technische Universität Dresden (Germany)
4  *
5  * This file is part of TUD:OS and distributed under the terms of the
6  * GNU General Public License 2.
7  * Please see the COPYING-GPL-2 file for details.
8  */
9 #include <l4/re/env>
10 #include <l4/re/namespace>
11 #include <l4/re/util/cap_alloc>
12 #include <l4/re/util/object_registry>
13 #include <l4/re/error_helper>
14
15 #include <l4/cxx/ipc_server>
16 #include <l4/cxx/ipc_timeout_queue>
17
18 #include "server.h"
19
20 L4::Cap<void> rcv_cap = L4Re::Util::cap_alloc.alloc<void>();
21
22 class Loop_hooks :
23   public L4::Ipc_svr::Timeout_queue_hooks<Loop_hooks>,
24   public L4::Ipc_svr::Ignore_errors
25 {
26 public:
27   static l4_kernel_clock_t now()
28   { return l4_kip_clock(l4re_kip()); }
29
30   static int timeout_br() { return 8; }
31
32   void setup_wait(L4::Ipc::Istream &istr, L4::Ipc_svr::Reply_mode mode)
33   {
34     L4::Ipc_svr::Timeout_queue_hooks<Loop_hooks>::setup_wait(istr, mode);
35     istr.reset();
36     istr << L4::Ipc::Small_buf(rcv_cap.cap(), L4_RCV_ITEM_LOCAL_ID);
37     l4_utcb_br()->bdr = 0;
38   }
39 };
40
41 static L4Re::Util::Registry_server<Loop_hooks> server;
42
43 L4Re::Util::Object_registry *registry = server.registry();
44 L4::Ipc_svr::Timeout_queue *timeouts = &server.queue;
45
46 int server_loop()
47 {
48   server.loop();
49   return 0;
50 }
51