]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/jdb/jdb_exit_module.cpp
update
[l4.git] / kernel / fiasco / src / jdb / jdb_exit_module.cpp
1 IMPLEMENTATION:
2
3 #include <cstdio>
4 #include "simpleio.h"
5
6 #include "jdb.h"
7 #include "jdb_module.h"
8 #include "jdb_screen.h"
9 #include "kernel_console.h"
10 #include "static_init.h"
11 #include "terminate.h"
12 #include "types.h"
13
14 /**
15  * Private 'exit' module.
16  *
17  * This module handles the 'exit' or '^' command that
18  * makes a call to exit() and virtually reboots the system.
19  */
20 class Jdb_exit_module : public Jdb_module
21 {
22 public:
23   Jdb_exit_module() FIASCO_INIT;
24 };
25
26 static Jdb_exit_module jdb_exit_module INIT_PRIORITY(JDB_MODULE_INIT_PRIO);
27
28 PUBLIC
29 Jdb_module::Action_code
30 Jdb_exit_module::action (int cmd, void *&, char const *&, int &)
31 {
32   if (cmd!=0)
33     return NOTHING;
34
35   // re-enable output of all consoles but GZIP and DEBUG
36   Kconsole::console()->change_state(0, Console::GZIP | Console::DEBUG,
37                                     ~0UL, Console::OUTENABLED);
38   // re-enable input of all consoles but PUSH and DEBUG
39   Kconsole::console()->change_state(0, Console::PUSH | Console::DEBUG,
40                                     ~0UL, Console::INENABLED);
41
42   Jdb::screen_scroll(1, 127);
43   Jdb::blink_cursor(Jdb_screen::height(), 1);
44   Jdb::cursor(127, 1);
45   vmx_off();
46   terminate(1);
47   return LEAVE;
48 }
49
50 PUBLIC
51 int
52 Jdb_exit_module::num_cmds() const
53 {
54   return 1;
55 }
56
57 PUBLIC
58 Jdb_module::Cmd const *
59 Jdb_exit_module::cmds() const
60 {
61   static Cmd cs[] =
62     { { 0, "^", "exit", "", "^\treboot the system", (void*)0 } };
63
64   return cs;
65 }
66
67 IMPLEMENT
68 Jdb_exit_module::Jdb_exit_module()
69   : Jdb_module("GENERAL")
70 {}
71
72 // ------------------------------------------------------------------------
73 IMPLEMENTATION [vmx]:
74
75 // VT might need some special treatment, switching VT off seems to be
76 // necessary to do a (keyboard) reset
77
78 #include "cpu.h"
79
80 PRIVATE static
81 void
82 Jdb_exit_module::do_vmxoff(unsigned, void *)
83 {
84   asm volatile("vmxoff");
85 }
86
87 PRIVATE static
88 void
89 Jdb_exit_module::remote_vmxoff(unsigned cpu)
90 {
91   Jdb::remote_work(cpu, do_vmxoff, 0);
92 }
93
94 PRIVATE
95 void
96 Jdb_exit_module::vmx_off() const
97 {
98   if (Cpu::boot_cpu()->vmx())
99     Jdb::foreach_cpu(&remote_vmxoff);
100 }
101
102 // ------------------------------------------------------------------------
103 IMPLEMENTATION [!vmx]:
104
105 PRIVATE
106 void
107 Jdb_exit_module::vmx_off() const {}