Rev 2178 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
2128 | jermar | 1 | /* |
2178 | kebrt | 2 | * Copyright (c) 2007 Michal Kebrt |
2180 | stepan | 3 | * Copyright (c) 2007 Petr Stepan |
4 | * |
||
2128 | jermar | 5 | * All rights reserved. |
6 | * |
||
7 | * Redistribution and use in source and binary forms, with or without |
||
8 | * modification, are permitted provided that the following conditions |
||
9 | * are met: |
||
10 | * |
||
11 | * - Redistributions of source code must retain the above copyright |
||
12 | * notice, this list of conditions and the following disclaimer. |
||
13 | * - Redistributions in binary form must reproduce the above copyright |
||
14 | * notice, this list of conditions and the following disclaimer in the |
||
15 | * documentation and/or other materials provided with the distribution. |
||
16 | * - The name of the author may not be used to endorse or promote products |
||
17 | * derived from this software without specific prior written permission. |
||
18 | * |
||
19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
||
20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
||
21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
||
22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
||
23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
||
24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
||
25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
||
26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
||
27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
||
28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
||
29 | */ |
||
30 | |||
31 | /** @addtogroup arm32 |
||
32 | * @{ |
||
33 | */ |
||
34 | /** @file |
||
35 | */ |
||
36 | |||
37 | #ifndef KERN_arm32_EXCEPTION_H_ |
||
38 | #define KERN_arm32_EXCEPTION_H_ |
||
39 | |||
40 | #include <arch/types.h> |
||
41 | |||
2180 | stepan | 42 | /* Exception Vectors */ |
43 | #define EXC_RESET_VEC 0x0 |
||
44 | #define EXC_UNDEF_INSTR_VEC 0x4 |
||
45 | #define EXC_SWI_VEC 0x8 |
||
46 | #define EXC_PREFETCH_ABORT_VEC 0xc |
||
47 | #define EXC_DATA_ABORT_VEC 0x10 |
||
48 | #define EXC_IRQ_VEC 0x18 |
||
49 | #define EXC_FIQ_VEC 0x1c |
||
50 | |||
2128 | jermar | 51 | typedef struct { |
2178 | kebrt | 52 | |
53 | uint32_t cpsr; |
||
54 | uint32_t retaddr; |
||
55 | |||
56 | uint32_t r0; |
||
57 | uint32_t r1; |
||
58 | uint32_t r2; |
||
59 | uint32_t r3; |
||
60 | uint32_t r4; |
||
61 | uint32_t r5; |
||
62 | uint32_t r6; |
||
63 | uint32_t r7; |
||
64 | uint32_t r8; |
||
65 | uint32_t r10; |
||
66 | uint32_t r11; |
||
67 | uint32_t r12; |
||
68 | uint32_t sp; |
||
69 | uint32_t lr; |
||
70 | |||
2128 | jermar | 71 | } istate_t; |
72 | |||
73 | static inline void istate_set_retaddr(istate_t *istate, uintptr_t retaddr) |
||
74 | { |
||
2178 | kebrt | 75 | istate->retaddr = retaddr; |
2128 | jermar | 76 | } |
77 | |||
78 | /** Return true if exception happened while in userspace */ |
||
79 | static inline int istate_from_uspace(istate_t *istate) |
||
80 | { |
||
2178 | kebrt | 81 | return !(istate->retaddr & 0x80000000); |
2128 | jermar | 82 | } |
83 | static inline unative_t istate_get_pc(istate_t *istate) |
||
84 | { |
||
2178 | kebrt | 85 | return istate->retaddr; |
2128 | jermar | 86 | } |
87 | |||
2180 | stepan | 88 | |
89 | extern void install_exception_handlers(void); |
||
90 | extern void exception_init(void); |
||
91 | |||
2128 | jermar | 92 | #endif |
93 | |||
94 | /** @} |
||
95 | */ |