1 | /************************************************************************** |
---|
2 | * |
---|
3 | * Copyright (c) 2013 Alcatel-Lucent |
---|
4 | * |
---|
5 | * Alcatel Lucent licenses this file to You under the Apache License, |
---|
6 | * Version 2.0 (the "License"); you may not use this file except in |
---|
7 | * compliance with the License. A copy of the License is contained the |
---|
8 | * file LICENSE at the top level of this repository. |
---|
9 | * You may also obtain a copy of the License at: |
---|
10 | * |
---|
11 | * http://www.apache.org/licenses/LICENSE-2.0 |
---|
12 | * |
---|
13 | * Unless required by applicable law or agreed to in writing, software |
---|
14 | * distributed under the License is distributed on an "AS IS" BASIS, |
---|
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
---|
16 | * See the License for the specific language governing permissions and |
---|
17 | * limitations under the License. |
---|
18 | * |
---|
19 | ************************************************************************** |
---|
20 | * |
---|
21 | * vectors_arm.S |
---|
22 | * |
---|
23 | * Minimalist exception handlers... |
---|
24 | * Catch the exception, call generic handler with exception-specific id. |
---|
25 | * |
---|
26 | * Original author: Ed Sutter (ed.sutter@alcatel-lucent.com) |
---|
27 | * |
---|
28 | */ |
---|
29 | |
---|
30 | #define _ASSEMBLY_ 1 |
---|
31 | |
---|
32 | #include "arm.h" |
---|
33 | |
---|
34 | #define MORE_CONTEXT_SIZE \ |
---|
35 | (ARM_EXCEPTION_FRAME_SIZE - ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET) |
---|
36 | |
---|
37 | #define EXCEPTIONSAVE(n) \ |
---|
38 | sub sp, #MORE_CONTEXT_SIZE ; \ |
---|
39 | stmdb sp!, {r0-r12} ; \ |
---|
40 | mov r4, #(n) ; \ |
---|
41 | ; \ |
---|
42 | b save_more_context ; \ |
---|
43 | |
---|
44 | .global undefined_instruction |
---|
45 | .global software_interrupt |
---|
46 | .global abort_prefetch |
---|
47 | .global abort_data |
---|
48 | .global not_assigned |
---|
49 | .global interrupt_request |
---|
50 | .global fast_interrupt_request |
---|
51 | |
---|
52 | undefined_instruction: |
---|
53 | EXCEPTIONSAVE(EXCTYPE_UNDEF) |
---|
54 | |
---|
55 | software_interrupt: |
---|
56 | EXCEPTIONSAVE(EXCTYPE_SWI) |
---|
57 | |
---|
58 | abort_prefetch: |
---|
59 | EXCEPTIONSAVE(EXCTYPE_ABORTP) |
---|
60 | |
---|
61 | abort_data: |
---|
62 | EXCEPTIONSAVE(EXCTYPE_ABORTD) |
---|
63 | |
---|
64 | not_assigned: |
---|
65 | EXCEPTIONSAVE(EXCTYPE_NOTASSGN) |
---|
66 | |
---|
67 | interrupt_request: |
---|
68 | EXCEPTIONSAVE(EXCTYPE_IRQ) |
---|
69 | |
---|
70 | fast_interrupt_request: |
---|
71 | EXCEPTIONSAVE(EXCTYPE_FIRQ) |
---|
72 | |
---|
73 | /* This code gratefully taken from RTEMS */ |
---|
74 | |
---|
75 | save_more_context: |
---|
76 | /* Save more context */ |
---|
77 | mov r2, lr |
---|
78 | mrs r3, spsr |
---|
79 | mrs r7, cpsr |
---|
80 | orr r5, r3, #ARM_PSR_I |
---|
81 | bic r5, #ARM_PSR_T |
---|
82 | msr cpsr, r5 |
---|
83 | mov r0, sp |
---|
84 | mov r1, lr |
---|
85 | msr cpsr, r7 |
---|
86 | mov r5, #0 |
---|
87 | add r6, sp, #ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET |
---|
88 | stm r6, {r0-r5} |
---|
89 | |
---|
90 | /* Argument for high level handler */ |
---|
91 | mov r0, sp |
---|
92 | |
---|
93 | /* Clear VFP context pointer */ |
---|
94 | add r3, sp, #ARM_EXCEPTION_FRAME_VFP_CONTEXT_OFFSET |
---|
95 | mov r1, #0 |
---|
96 | str r1, [r3] |
---|
97 | |
---|
98 | /* Call high level handler */ |
---|
99 | b umon_exception |
---|
100 | |
---|
101 | /* Just in case */ |
---|
102 | twiddle: |
---|
103 | b twiddle |
---|
104 | |
---|