blob: 0c881b917bd975bc4160f705729fe9c7770f89d8 [file] [log] [blame]
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -07001/*
2 * Copyright (c) 2008 Travis Geiselbrecht
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining
5 * a copy of this software and associated documentation files
6 * (the "Software"), to deal in the Software without restriction,
7 * including without limitation the rights to use, copy, modify, merge,
8 * publish, distribute, sublicense, and/or sell copies of the Software,
9 * and to permit persons to whom the Software is furnished to do so,
10 * subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be
13 * included in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
16 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
17 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
18 * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
19 * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
20 * TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
21 * SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 */
23#include <asm.h>
24
25FUNCTION(arm_undefined)
26 stmfd sp!, { r0-r12, r14 }
27 sub sp, sp, #12
28 mov r0, sp
29 mrs r1, spsr
30 stmia r0, { r1, r13-r14 }^
31 b arm_undefined_handler
32 b .
33
34FUNCTION(arm_syscall)
35 stmfd sp!, { r0-r12, r14 }
36 sub sp, sp, #12
37 mov r0, sp
38 mrs r1, spsr
39 stmia r0, { r1, r13-r14 }^
40 b arm_syscall_handler
41 b .
42
43FUNCTION(arm_prefetch_abort)
44 stmfd sp!, { r0-r12, r14 }
45 sub sp, sp, #12
46 mov r0, sp
47 mrs r1, spsr
48 stmia r0, { r1, r13-r14 }^
49 b arm_prefetch_abort_handler
50 b .
51
52FUNCTION(arm_data_abort)
53 stmfd sp!, { r0-r12, r14 }
54 sub sp, sp, #12
55 mov r0, sp
56 mrs r1, spsr
57 stmia r0, { r1, r13-r14 }^
58 b arm_data_abort_handler
59 b .
60
61FUNCTION(arm_reserved)
62 b .
63
64FUNCTION(arm_irq)
65 /* XXX only deals with interrupting supervisor mode */
66
67 /* save r4-r6 and use as a temporary place to save while we switch into supervisor mode */
68 stmia r13, { r4-r6 }
69 mov r4, r13
70 sub r5, lr, #4
71 mrs r6, spsr
72
73 /* move into supervisor mode. irq/fiq disabled */
74 msr cpsr_c, #(3<<6 | 0x13)
75
76 /* save the return address */
77 stmfd sp!, { r5 }
78
79 /* save C trashed regs, supervisor lr */
80 stmfd sp!, { r0-r3, r12, lr }
81
82 /* save spsr */
83 stmfd sp!, { r6 }
84
85 /* restore r4-r6 */
86 ldmia r4, { r4-r6 }
87
88 /* increment the global critical section count */
89 ldr r1, =critical_section_count
90 ldr r0, [r1]
91 add r0, r0, #1
92 str r0, [r1]
93
94 /* call into higher level code */
95 mov r0, sp /* iframe */
96 bl platform_irq
97
98 /* reschedule if the handler returns nonzero */
99 cmp r0, #0
100 blne thread_preempt
101
102 /* decrement the global critical section count */
103 ldr r1, =critical_section_count
104 ldr r0, [r1]
105 sub r0, r0, #1
106 str r0, [r1]
107
108 /* restore spsr */
109 ldmfd sp!, { r0 }
Travis Geiselbrecht3db83802009-01-16 20:10:29 -0800110 msr spsr_cxsf, r0
Travis Geiselbrecht1d0df692008-09-01 02:26:09 -0700111
112 /* restore back to where we came from */
113 ldmfd sp!, { r0-r3, r12, lr, pc }^
114
115.bss
116.align 2
117 .global irq_save_spot
118irq_save_spot:
119 .word 0 /* r4 */
120 .word 0 /* r5 */
121 .word 0 /* r6 */
122
123.text
124FUNCTION(arm_fiq)
125 sub lr, lr, #4
126 stmfd sp!, { r0-r3, r12, lr }
127
128 bl platform_fiq
129
130 ldmfd sp!, { r0-r3, r12, pc }^
131
132.ltorg