source: mainline/kernel/arch/arm32/src/exc_handler.S

Last change on this file was a35b458, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

  • Property mode set to 100644
File size: 4.6 KB
Line 
1#
2# Copyright (c) 2009 Vineeth Pillai
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29#include <abi/asmtool.h>
30
31.text
32
33# Switches to kernel stack and saves all registers there.
34#
35# The stack frame created by the function looks like:
36#
37# |_________________|
38# | |
39# | SPSR |
40# | |
41# |_________________|
42# | Stack Pointer |
43# | of |
44# | Previous Mode |
45# |_________________|
46# | Return address |
47# | of |
48# | Previous Mode |
49# |_________________|
50# | R0 - R12 |
51# | of |
52# | Previous Mode |
53# |_________________|
54# | Return address |
55# | from |
56# |Exception Handler|
57# |_________________|
58# | |
59#
60#
61
62.macro SAVE_REGS_TO_STACK
63 stmfd r13!, {r0-r3}
64 mov r3, sp
65 add sp, sp, #16
66 mrs r1, cpsr
67 bic r1, r1, #0x1f
68 mrs r2, spsr
69 and r0, r2, #0x1f
70 cmp r0, #0x10
71 bne 1f
72
73 # prev mode was usermode
74 mov r0, lr
75
76 # Switch to supervisor mode
77 orr r1, r1, #0x13
78 msr cpsr_c, r1
79
80 # Load sp with [supervisor_sp]
81 ldr r13, =supervisor_sp
82 ldr r13, [r13]
83
84 # Populate the stack frame
85 msr spsr, r2
86 mov lr, r0
87 stmfd r13!, {lr}
88 stmfd r13!, {r4-r12}
89 ldmfd r3!, {r4-r7}
90 stmfd r13!, {r4-r7}
91 mov r4, r13
92 stmfd r4, {r13, lr}^
93 nop /* Cannot access r13 immediately after stm(2) */
94 sub r13, r13, #8
95 stmfd r13!, {r2}
96
97 # Stop stack traces here
98 mov fp, #0
99
100 b 2f
101
102 # mode was not usermode
1031:
104 # Switch to previous mode which is undoubtedly the supervisor mode
105 orr r1, r1, r0
106 mov r0, lr
107 msr cpsr_c, r1
108
109 # Populate the stack frame
110 mov r1, sp
111 stmfd r13!, {r0}
112 stmfd r13!, {r4-r12}
113
114 # Store r0-r3 in r4-r7 and then push it on to stack
115 ldmfd r3!, {r4-r7}
116 stmfd r13!, {r4-r7}
117
118 # Push return address and stack pointer on to stack
119 stmfd r13!, {lr}
120 stmfd r13!, {r1}
121 mov lr, r0
122 msr spsr, r2
123 stmfd r13!, {r2}
1242:
125 sub sp, sp, #4
126.endm
127
128.macro LOAD_REGS_FROM_STACK
129 add sp, sp, #4
130 ldmfd r13!, {r0}
131 msr spsr, r0
132 and r0, r0, #0x1f
133 cmp r0, #0x10
134 bne 1f
135
136 # return to user mode
137 mov r0, r13
138 ldmfd r0, {r13, lr}^
139 nop /* Cannot access r13 immediately after ldm(2) */
140 add r13, r13, #8
141 b 2f
142
143 # return to non-user mode
1441:
145 ldmfd r13!, {r1, lr}
146
1472:
148 ldmfd r13!, {r0-r12, pc}^
149.endm
150
151SYMBOL(reset_exception_entry)
152 SAVE_REGS_TO_STACK
153 mov r0, #0
154 mov r1, r13
155 bl ras_check
156 LOAD_REGS_FROM_STACK
157
158SYMBOL(irq_exception_entry)
159 sub lr, lr, #4
160 SAVE_REGS_TO_STACK
161 mov r0, #5
162 mov r1, r13
163 bl ras_check
164 LOAD_REGS_FROM_STACK
165
166SYMBOL(fiq_exception_entry)
167 sub lr, lr, #4
168 SAVE_REGS_TO_STACK
169 mov r0, #6
170 mov r1, r13
171 bl ras_check
172 LOAD_REGS_FROM_STACK
173
174SYMBOL(undef_instr_exception_entry)
175 SAVE_REGS_TO_STACK
176 mov r0, #1
177 mov r1, r13
178 bl ras_check
179 LOAD_REGS_FROM_STACK
180
181SYMBOL(prefetch_abort_exception_entry)
182 sub lr, lr, #4
183 SAVE_REGS_TO_STACK
184 mov r0, #3
185 mov r1, r13
186 bl ras_check
187 LOAD_REGS_FROM_STACK
188
189SYMBOL(data_abort_exception_entry)
190 sub lr, lr, #8
191 SAVE_REGS_TO_STACK
192 mov r0, #4
193 mov r1, r13
194 bl ras_check
195 LOAD_REGS_FROM_STACK
196
197SYMBOL(swi_exception_entry)
198 ldr r13, =exc_stack
199 SAVE_REGS_TO_STACK
200 mov r0, #2
201 mov r1, r13
202 bl ras_check
203 LOAD_REGS_FROM_STACK
204
Note: See TracBrowser for help on using the repository browser.