]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/ppc32/trap_state.cpp
020d6c14ebc876a86a5257a6bc15a0c42ae34393
[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*, unsigned cpu);
21   bool exclude_logging() { return false; }
22 };
23
24
25 IMPLEMENTATION:
26
27 #include <cstdio>
28
29 PUBLIC inline
30 void
31 Trap_state::sanitize_user_state()
32 {
33   // implement me
34 }
35
36 PUBLIC inline
37 unsigned long
38 Trap_state::ip() const
39 { return srr0; }
40
41 PUBLIC inline
42 unsigned long
43 Trap_state::trapno() const
44 { return error_code; }
45
46 PUBLIC inline
47 Mword
48 Trap_state::error() const
49 { return 0; }
50
51 PUBLIC inline
52 void
53 Trap_state::set_ipc_upcall()
54 {
55   error_code = 0x10000000; // see Msr
56 }
57
58 PUBLIC inline
59 void
60 Trap_state::set_pagefault(Mword pfa, Mword error)
61 {
62   pf_address = pfa;
63   error_code = error;
64 }
65
66 PUBLIC inline
67 bool
68 Trap_state::is_debug_exception() const
69 { return false; }
70
71 PUBLIC
72 void
73 Trap_state::dump()
74 {
75   char const *excpts[] = 
76     {"reset","machine check"};
77   
78   printf("EXCEPTION: pfa=%08lx, error=%08lx\n",
79          //excpts[((error_code & ~0xff) >> 8) - 1]
80           pf_address, error_code);
81
82   printf("SP: %08lx LR: %08lx SRR0: %08lx SRR1 %08lx\n\n"
83          "R[0]  %08lx\n"
84          "R[3]: %08lx %08lx %08lx %08lx %08lx\n"
85          "R[8]: %08lx %08lx %08lx %08lx %08lx\n",
86          usp, ulr, srr0, srr1,
87          r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7],
88          r[8], r11, r12);
89 }
90