]> rtime.felk.cvut.cz Git - l4.git/blob - kernel/fiasco/src/kern/arm/trap_state.cpp
1a30941762cfaabad22dfbeb267801fae4876103
[l4.git] / kernel / fiasco / src / kern / arm / 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 public:
10 //  static int (*base_handler)(Trap_state *) asm ("BASE_TRAP_HANDLER");
11
12   Mword pf_address;
13   Mword error_code;
14
15   Mword r[13];
16 };
17
18
19 class Trap_state : public Trap_state_regs, public Return_frame
20 {
21 public:
22   typedef int (*Handler)(Trap_state*, unsigned cpu);
23 };
24
25
26 IMPLEMENTATION:
27
28 #include <cstdio>
29 #include "processor.h"
30
31 PUBLIC inline NEEDS["processor.h"]
32 void
33 Trap_state::sanitize_user_state()
34 {
35   psr &= ~(Proc::Status_mode_mask | Proc::Status_interrupts_mask);
36   psr |= Proc::Status_mode_user;
37 }
38
39 PUBLIC inline
40 void
41 Trap_state::set_ipc_upcall()
42 {
43   error_code = 0x00600000;
44 }
45
46 PUBLIC inline
47 void
48 Trap_state::set_pagefault(Mword pfa, Mword error)
49 {
50   pf_address = pfa;
51   error_code = error;
52 }
53
54 PUBLIC inline
55 unsigned long
56 Trap_state::ip() const
57 { return pc; }
58
59 PUBLIC inline
60 unsigned long
61 Trap_state::trapno() const
62 { return error_code >> 16; }
63
64 PUBLIC inline
65 Mword
66 Trap_state::error() const
67 { return error_code; }
68
69 PUBLIC inline
70 bool
71 Trap_state::exception_is_undef_insn() const
72 { return (error_code & 0x00f00000) == 0x00100000; }
73
74 PUBLIC inline
75 bool
76 Trap_state::is_debug_exception() const
77 { return false; }
78
79 PUBLIC
80 void
81 Trap_state::dump()
82 {
83   char const *excpts[] =
84     { "reset", "undefined insn", "swi", "prefetch abort",
85       "data abort", "trigexc", "%&#", "%&#" };
86
87   printf("EXCEPTION: %s pfa=%08lx, error=%08lx\n",
88          excpts[(error_code & 0x00700000) >> 20], pf_address, error_code);
89
90   printf("R[0]: %08lx %08lx %08lx %08lx  %08lx %08lx %08lx %08lx\n"
91          "R[8]: %08lx %08lx %08lx %08lx  %08lx %08lx %08lx %08lx\n",
92          r[0], r[1], r[2], r[3], r[4], r[5], r[6], r[7],
93          r[8], r[9], r[10], r[11], r[12], usp, ulr, pc);
94 }
95