]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ia32/64/thread-dbf.cpp
update
[l4.git] / kernel / fiasco / src / kern / ia32 / 64 / thread-dbf.cpp
1 INTERFACE[amd64]:
2
3 EXTENSION class Thread
4 {
5 private:
6   static void handle_double_fault (Trap_state *) asm ("thread_handle_double_fault");
7
8 public:
9   static bool may_enter_jdb;
10 };
11
12
13 IMPLEMENTATION[amd64]:
14
15 #include <cstdio>
16 #include "cpu.h"
17 #include "kernel_console.h"
18 #include "processor.h"
19 #include "reset.h"
20 #include "trap_state.h"
21 #include "tss.h"
22 #include "watchdog.h"
23
24
25 bool Thread::may_enter_jdb = false;
26
27 IMPLEMENT
28 void
29 Thread::handle_double_fault (Trap_state *ts)
30 {
31   int c;
32
33   Watchdog::disable();
34      printf ("\n\033[1;31mDOUBLE FAULT!\033[m\n"
35              "RAX=%016lx  RSI=%016lx\n"
36              "RBX=%016lx  RDI=%016lx\n"
37              "RCX=%016lx  RBP=%016lx\n"
38              "RDX=%016lx  RSP=%016lx\n"
39              "R8= %016lx  R9= %016lx\n"
40              "R10=%016lx  R11=%016lx\n"
41              "R12=%016lx  R13=%016lx\n"
42              "R14=%016lx  R15=%016lx\n"
43              "RIP %016lx  RFLAGS %016lx\n"
44              "CS %04lx    SS %04lx\n\n",
45              ts->_ax, ts->_si,
46              ts->_bx, ts->_di,
47              ts->_cx, ts->_bp,
48              ts->_dx, ts->sp(),
49              ts->_r8,  ts->_r9,
50              ts->_r10, ts->_r11,
51              ts->_r12, ts->_r13,
52              ts->_r14, ts->_r15,
53              ts->ip(), ts->flags(),
54              ts->cs() & 0xffff, ts->ss() & 0xffff);
55   if (may_enter_jdb)
56     {
57       puts ("Return reboots, \"k\" tries to enter the L4 kernel debugger...");
58
59       while ((c=Kconsole::console()->getchar(false)) == -1)
60         Proc::pause();
61
62       if (c == 'k' || c == 'K')
63         {
64              nested_trap_handler(ts,0); // XXX: 0 is possibly the wrong CPU
65         }
66     }
67   else
68     {
69       puts ("Return reboots");
70       while ((Kconsole::console()->getchar(false)) == -1)
71         Proc::pause();
72     }
73
74   puts ("\033[1mRebooting...\033[0m");
75   platform_reset();
76 }
77
78