]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/sparc/thread-jdb.cpp
update
[l4.git] / kernel / fiasco / src / kern / sparc / thread-jdb.cpp
1 INTERFACE [sparc && debug]:
2
3 #include "trap_state.h"
4 #include "util.h"
5
6 EXTENSION class Thread
7 {
8 public:
9   typedef void (*Dbg_extension_entry)(Thread *t, Entry_frame *r);
10   static Dbg_extension_entry dbg_extension[64];
11 private:
12   static int call_nested_trap_handler(Trap_state *ts) asm ("call_nested_trap_handler");
13   static Trap_state::Handler nested_trap_handler FIASCO_FASTCALL;
14 };
15
16 //------------------------------------------------------------------------------
17 IMPLEMENTATION [sparc && debug]:
18
19 Thread::Dbg_extension_entry Thread::dbg_extension[64];
20 Trap_state::Handler Thread::nested_trap_handler FIASCO_FASTCALL;
21
22 extern "C" void sys_kdb_ke()
23 {
24   cpu_lock.lock();
25   Thread *t = current_thread();
26
27   //arriving from outx function
28   //unsigned *x = (unsigned *)t->regs()->ip();
29   if(t->regs()->r[29] == (Mword)-0x24 && t->regs()->r[2] & (1 << 31)) //ip && r3
30     {
31       NOT_IMPL_PANIC;
32       unsigned func = (unsigned)t->regs()->r[1] & 0xffff; //r4
33       if(Thread::dbg_extension[func])
34         {
35           Thread::dbg_extension[func](t, t->regs());
36           return;
37         }
38     }
39
40   char str[32] = "USER ENTRY";
41   //arriving from enter_kdebug
42   if (t->regs()->r[29] == (Mword)-0x24 && t->regs()->r[2] & (1 << 30)) //ip && r3
43     {
44       //t->mem_space()->copy_from_user(str, (char *)(x + 1), sizeof(str));
45       str[sizeof(str)-1] = 0;
46     }
47
48   kdb_ke(str);
49 }
50
51 IMPLEMENT
52 int
53 Thread::call_nested_trap_handler(Trap_state * /*ts*/)
54 {
55   Cpu_phys_id phys_cpu = Proc::cpu_id();
56   Cpu_number log_cpu = Cpu::cpus.find_cpu(Cpu::By_phys_id(phys_cpu));
57   if (log_cpu == Cpu_number::nil())
58     {
59       printf("Trap on unknown CPU phys_id=%x\n", cxx::int_value<Cpu_phys_id>(phys_cpu));
60       log_cpu = Cpu_number::boot_cpu();
61     }
62
63   unsigned long &ntr = nested_trap_recover.cpu(log_cpu);
64
65   void *stack = 0;
66
67   if (!ntr)
68     stack = dbg_stack.cpu(log_cpu).stack_top;
69
70   return 0;
71 }
72
73 IMPLEMENTATION [sparc && !debug]:
74
75 extern "C" void sys_kdb_ke()
76 {
77 }
78 extern "C" void enter_jdb()
79 {}