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
run(int argc,char const * const * argv)33 run(int argc, char const *const *argv)
34 {
35   Dbg::set_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 
61   lua(argc, argv);
62 
63 
64   while (1)
65     l4_sleep_forever();
66 
67   return 0;
68 };
69 
70 int
main(int argc,char const * const * argv)71 main(int argc, char const *const *argv)
72 {
73   try
74     {
75       return run(argc, argv);
76     }
77   catch (L4::Runtime_error &e)
78     {
79       L4::cerr << "FATAL: " << e;
80       l4_sleep_forever();
81     }
82 
83   l4_sleep_forever();
84   return 0;
85 }
86