]> rtime.felk.cvut.cz Git - l4.git/blob - l4/pkg/ned/server/src/main.cc
2338bc7ed2b7d9b05b40dad2f712c949cf9d6f25
[l4.git] / l4 / pkg / ned / server / src / main.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 "app_model.h"
10 #include "debug.h"
11
12 #include <l4/libloader/elf>
13 #include <l4/cxx/iostream>
14 #include <l4/util/util.h>
15 #include <cstdio>
16
17 #include "lua.h"
18 #include "server.h"
19
20 static Dbg info(Dbg::Info);
21 static Dbg boot_info(Dbg::Boot);
22 l4re_aux_t* l4re_aux;
23
24 //static Ned::Server s(l4_utcb(), Ned::Registry(L4Re::Env::env()->main_thread(), L4Re::Env::env()->factory()));
25
26
27 Ned::Server *Ned::server;// = &s;
28
29 static Dbg ldr(Dbg::Loader, "ldr");
30
31 static
32 int
33 run(int argc, char const *const *argv)
34 {
35   Dbg::level = Dbg::Warn;
36   info.printf("Hello from Ned\n");
37
38   boot_info.printf("cmdline: ");
39   for (int i = 0; i < argc; ++i)
40     boot_info.cprintf("%s ", argv[i]);
41   boot_info.cprintf("\n");
42
43   l4_umword_t *auxp = (l4_umword_t*)&argv[argc] + 1;
44   while (*auxp)
45     ++auxp;
46   ++auxp;
47
48   l4re_aux = 0;
49
50   while (*auxp)
51     {
52       if (*auxp == 0xf0)
53         l4re_aux = (l4re_aux_t*)auxp[1];
54       auxp += 2;
55     }
56
57   Ned::Server svr;
58   Ned::server = &svr;
59
60   lua(argc, argv);
61
62
63   while (1)
64     l4_sleep_forever();
65
66   return 0;
67 };
68
69 int
70 main(int argc, char const *const *argv)
71 {
72   try
73     {
74       return run(argc, argv);
75     }
76   catch (L4::Runtime_error &e)
77     {
78       L4::cerr << "FATAL: " << e;
79       l4_sleep_forever();
80     }
81
82   l4_sleep_forever();
83   return 0;
84 }