]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/kernel_console.cpp
update
[l4.git] / kernel / fiasco / src / kern / kernel_console.cpp
1 INTERFACE:
2
3 #include "mux_console.h"
4 #include "std_macros.h"
5
6 class Kconsole : public Mux_console
7 {
8 public:
9   int  getchar(bool blocking = true);
10   void getchar_chance();
11
12   static Mux_console *console() FIASCO_CONST
13   { return _c.get(); }
14
15 private:
16   static Static_object<Kconsole> _c;
17 };
18
19 IMPLEMENTATION:
20
21 #include "config.h"
22 #include "console.h"
23 #include "mux_console.h"
24 #include "processor.h"
25
26
27 IMPLEMENT
28 int Kconsole::getchar(bool blocking)
29 {
30   if (!blocking)
31     return Mux_console::getchar(false);
32
33   while (1)
34     {
35       int c;
36       if ((c = Mux_console::getchar(false)) != -1)
37         return c;
38
39       if (Config::getchar_does_hlt &&           // does work in principle
40           Config::getchar_does_hlt_works_ok &&  // wakeup timer is enabled
41           Proc::interrupts())                   // does'nt work without ints
42         Proc::halt();
43       else
44         Proc::pause();
45     }
46 }
47
48 Static_object<Kconsole> Kconsole::_c;
49
50
51 PUBLIC static FIASCO_NOINLINE
52 void
53 Kconsole::init()
54 { _c.init(); }
55
56
57 PUBLIC inline
58 Kconsole::Kconsole()
59 {
60   Console::stdout = this;
61   Console::stderr = this;
62   Console::stdin  = this;
63 }
64