]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ppc32/trap_state.cpp
Update
[l4.git] / kernel / fiasco / src / kern / ppc32 / trap_state.cpp
1
2 INTERFACE:
3
4 #include "l4_types.h"
5 #include "entry_frame.h"
6
7 class Trap_state_regs
8 {
9 //  static int (*base_handler)(Trap_state *) asm ("BASE_TRAP_HANDLER");
10 public:
11   Mword pf_address;
12   Mword error_code;
13 };
14
15
16 class Trap_state : public Trap_state_regs, public Syscall_frame,
17                    public Return_frame
18 {
19 public:
20   typedef int (*Handler)(Trap_state*, Cpu_number::Value cpu);
21   bool exclude_logging() { return false; }
22 };
23
24 struct Trex
25 {
26   Trap_state s;
27   void set_ipc_upcall()
28   { s.error_code = 0x10000000; /* see Msr */ }
29
30   void dump() { s.dump(); }
31 };
32
33
34 IMPLEMENTATION:
35
36 #include <cstdio>
37
38 PUBLIC inline
39 void
40 Trap_state::copy_and_sanitize(Trap_state const *)
41 {
42   // FIXME: unimplemented
43 }
44
45 PUBLIC inline
46 unsigned long
47 Trap_state::ip() const
48 { return srr0; }
49
50 PUBLIC inline
51 unsigned long
52 Trap_state::trapno() const
53 { return error_code; }
54
55 PUBLIC inline
56 Mword
57 Trap_state::error() const
58 { return 0; }
59
60 PUBLIC inline
61 void
62 Trap_state::set_pagefault(Mword pfa, Mword error)
63 {
64   pf_address = pfa;
65   error_code = error;
66 }
67
68 PUBLIC inline
69 bool
70 Trap_state::is_debug_exception() const
71 { return false; }
72
73 PUBLIC
74 void
75 Trap_state::dump()
76 {
77   char const *excpts[] = 
78     {"reset","machine check"};
79   
80   printf("EXCEPTION: pfa=%08lx, error=%08lx\n",
81          //excpts[((error_code & ~0xff) >> 8) - 1]
82           pf_address, error_code);
83
84   printf("SP: %08lx LR: %08lx SRR0: %08lx SRR1 %08lx\n\n"
85          "R[0]  %08lx\n"
86          "R[3]: %08lx %08lx %08lx %08lx %08lx\n"
87          "R[8]: %08lx %08lx %08lx %08lx %08lx\n",
88          usp, ulr, srr0, srr1,
89          r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7],
90          r[8], r11, r12);
91 }
92