]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/kernel_console.cpp
Some minor fixes.
[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; }
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 Static_object<Kconsole> Kconsole::_c;
27
28
29 IMPLEMENT
30 int Kconsole::getchar(bool blocking)
31 {
32   if (!blocking)
33     return Mux_console::getchar(false);
34
35   while (1)
36     {
37       int c;
38       if ((c = Mux_console::getchar(false)) != -1)
39         return c;
40
41       if (Config::getchar_does_hlt_works_ok // wakeup timer is enabled
42           && Proc::interrupts())            // does'nt work without ints
43         Proc::halt();
44       else
45         Proc::pause();
46     }
47 }
48
49
50 PUBLIC inline
51 Kconsole::Kconsole()
52 {
53   Console::stdout = this;
54   Console::stderr = this;
55   Console::stdin  = this;
56 }
57
58
59 PUBLIC static FIASCO_NOINLINE
60 void
61 Kconsole::init()
62 { _c.construct(); }
63
64