summaryrefslogtreecommitdiffstats
path: root/main/cpu/arm/vectors_arm.S
blob: 128c4ac06a48cfc81d1754175786973d914a19fd (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/**************************************************************************
 *
 * Copyright (c) 2013 Alcatel-Lucent
 *
 * Alcatel Lucent licenses this file to You under the Apache License,
 * Version 2.0 (the "License"); you may not use this file except in
 * compliance with the License.  A copy of the License is contained the
 * file LICENSE at the top level of this repository.
 * You may also obtain a copy of the License at:
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 **************************************************************************
 *
 * vectors_arm.S
 *
 * Minimalist exception handlers...
 * Catch the exception, call generic handler with exception-specific id.
 *
 * Original author:     Ed Sutter (ed.sutter@alcatel-lucent.com)
 *
 */

#define _ASSEMBLY_ 1

#include "arm.h"

#define MORE_CONTEXT_SIZE \
  (ARM_EXCEPTION_FRAME_SIZE - ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET)

#define EXCEPTIONSAVE(n)         \
	sub     sp, #MORE_CONTEXT_SIZE	 ; \
        stmdb   sp!, {r0-r12}	 ; \
        mov     r4, #(n)	 ; \
	 ; \
        b       save_more_context	 ; \

.global undefined_instruction
.global software_interrupt
.global abort_prefetch
.global abort_data
.global not_assigned
.global interrupt_request
.global fast_interrupt_request

undefined_instruction:
EXCEPTIONSAVE(EXCTYPE_UNDEF)

software_interrupt:
EXCEPTIONSAVE(EXCTYPE_SWI)

abort_prefetch:
EXCEPTIONSAVE(EXCTYPE_ABORTP)

abort_data:
EXCEPTIONSAVE(EXCTYPE_ABORTD)

not_assigned:
EXCEPTIONSAVE(EXCTYPE_NOTASSGN)

interrupt_request:
EXCEPTIONSAVE(EXCTYPE_IRQ)

fast_interrupt_request:
EXCEPTIONSAVE(EXCTYPE_FIRQ)

/* This code gratefully taken from RTEMS */

save_more_context:
        /* Save more context */
        mov     r2, lr
        mrs     r3, spsr
        mrs     r7, cpsr
        orr     r5, r3, #ARM_PSR_I
        bic     r5, #ARM_PSR_T
        msr     cpsr, r5
        mov     r0, sp
        mov     r1, lr
        msr     cpsr, r7
        mov     r5, #0
        add     r6, sp, #ARM_EXCEPTION_FRAME_REGISTER_SP_OFFSET
        stm     r6, {r0-r5}

        /* Argument for high level handler */
        mov     r0, sp

        /* Clear VFP context pointer */
        add     r3, sp, #ARM_EXCEPTION_FRAME_VFP_CONTEXT_OFFSET
        mov     r1, #0
        str     r1, [r3]

        /* Call high level handler */
	b umon_exception

        /* Just in case */
twiddle:
        b       twiddle