source: mainline/kernel/arch/ppc32/src/exception.S@ 7a38962

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 7a38962 was c0699467, checked in by Martin Decky <martin@…>, 14 years ago

do not provide general access to kernel headers from uspace, only allow specific headers to be accessed or shared
externalize headers which serve as kernel/uspace API/ABI into a special tree

  • Property mode set to 100644
File size: 4.7 KB
Line 
1#
2# Copyright (c) 2006 Martin Decky
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 <arch/asm/regname.h>
30#include <arch/msr.h>
31#include <arch/mm/page.h>
32
33.section K_UNMAPPED_TEXT_START, "ax"
34
35.macro CONTEXT_STORE
36
37 # save r12 in SPRG1, backup CR in r12
38 # save SP in SPRG2
39
40 mtsprg1 r12
41 mfcr r12
42 mtsprg2 sp
43
44 # check whether SP is in kernel
45
46 andis. sp, sp, 0x8000
47 bne 1f
48
49 # stack is in user-space
50
51 mfsprg0 sp
52
53 b 2f
54
55 1:
56
57 # stack is in kernel
58
59 mfsprg2 sp
60 subis sp, sp, 0x8000
61
62 2:
63
64 subi sp, sp, 164
65 stw r0, 8(sp)
66 stw r2, 12(sp)
67 stw r3, 16(sp)
68 stw r4, 20(sp)
69 stw r5, 24(sp)
70 stw r6, 28(sp)
71 stw r7, 32(sp)
72 stw r8, 36(sp)
73 stw r9, 40(sp)
74 stw r10, 44(sp)
75 stw r11, 48(sp)
76 stw r13, 52(sp)
77 stw r14, 56(sp)
78 stw r15, 60(sp)
79 stw r16, 64(sp)
80 stw r17, 68(sp)
81 stw r18, 72(sp)
82 stw r19, 76(sp)
83 stw r20, 80(sp)
84 stw r21, 84(sp)
85 stw r22, 88(sp)
86 stw r23, 92(sp)
87 stw r24, 96(sp)
88 stw r25, 100(sp)
89 stw r26, 104(sp)
90 stw r27, 108(sp)
91 stw r28, 112(sp)
92 stw r29, 116(sp)
93 stw r30, 120(sp)
94 stw r31, 124(sp)
95
96 stw r12, 128(sp)
97
98 mfsrr0 r12
99 stw r12, 132(sp)
100
101 mfsrr1 r12
102 stw r12, 136(sp)
103
104 mflr r12
105 stw r12, 140(sp)
106
107 mfctr r12
108 stw r12, 144(sp)
109
110 mfxer r12
111 stw r12, 148(sp)
112
113 mfdar r12
114 stw r12, 152(sp)
115
116 mfsprg1 r12
117 stw r12, 156(sp)
118
119 mfsprg2 r12
120 stw r12, 160(sp)
121.endm
122
123.org 0x100
124.global exc_system_reset
125exc_system_reset:
126 CONTEXT_STORE
127
128 li r3, 0
129 b jump_to_kernel
130
131.org 0x200
132.global exc_machine_check
133exc_machine_check:
134 CONTEXT_STORE
135
136 li r3, 1
137 b jump_to_kernel
138
139.org 0x300
140.global exc_data_storage
141exc_data_storage:
142 CONTEXT_STORE
143
144 li r3, 2
145 b jump_to_kernel
146
147.org 0x400
148.global exc_instruction_storage
149exc_instruction_storage:
150 CONTEXT_STORE
151
152 li r3, 3
153 b jump_to_kernel
154
155.org 0x500
156.global exc_external
157exc_external:
158 CONTEXT_STORE
159
160 li r3, 4
161 b jump_to_kernel
162
163.org 0x600
164.global exc_alignment
165exc_alignment:
166 CONTEXT_STORE
167
168 li r3, 5
169 b jump_to_kernel
170
171.org 0x700
172.global exc_program
173exc_program:
174 CONTEXT_STORE
175
176 li r3, 6
177 b jump_to_kernel
178
179.org 0x800
180.global exc_fp_unavailable
181exc_fp_unavailable:
182 CONTEXT_STORE
183
184 li r3, 7
185 b jump_to_kernel
186
187.org 0x900
188.global exc_decrementer
189exc_decrementer:
190 CONTEXT_STORE
191
192 li r3, 8
193 b jump_to_kernel
194
195.org 0xa00
196.global exc_reserved0
197exc_reserved0:
198 CONTEXT_STORE
199
200 li r3, 9
201 b jump_to_kernel
202
203.org 0xb00
204.global exc_reserved1
205exc_reserved1:
206 CONTEXT_STORE
207
208 li r3, 10
209 b jump_to_kernel
210
211.org 0xc00
212.global exc_syscall
213exc_syscall:
214 CONTEXT_STORE
215
216 b jump_to_kernel_syscall
217
218.org 0xd00
219.global exc_trace
220exc_trace:
221 CONTEXT_STORE
222
223 li r3, 12
224 b jump_to_kernel
225
226.org 0x1000
227.global exc_itlb_miss
228exc_itlb_miss:
229 CONTEXT_STORE
230
231 li r3, 13
232 b jump_to_kernel
233
234.org 0x1100
235.global exc_dtlb_miss_load
236exc_dtlb_miss_load:
237 CONTEXT_STORE
238
239 li r3, 14
240 b jump_to_kernel
241
242.org 0x1200
243.global exc_dtlb_miss_store
244exc_dtlb_miss_store:
245 CONTEXT_STORE
246
247 li r3, 15
248 b jump_to_kernel
249
250.org 0x4000
251jump_to_kernel:
252 lis r12, iret@ha
253 addi r12, r12, iret@l
254 mtlr r12
255
256 lis r12, exc_dispatch@ha
257 addi r12, r12, exc_dispatch@l
258 mtsrr0 r12
259
260 mfmsr r12
261 ori r12, r12, (MSR_IR | MSR_DR)@l
262 mtsrr1 r12
263
264 addis sp, sp, 0x8000
265 mr r4, sp
266 addi r4, r4, 8
267
268 rfi
269
270jump_to_kernel_syscall:
271 lis r12, syscall_handler@ha
272 addi r12, r12, syscall_handler@l
273 mtsrr0 r12
274
275 lis r12, iret_syscall@ha
276 addi r12, r12, iret_syscall@l
277 mtlr r12
278
279 mfmsr r12
280 ori r12, r12, (MSR_IR | MSR_DR)@l
281 mtsrr1 r12
282
283 addis sp, sp, 0x8000
284 rfi
Note: See TracBrowser for help on using the repository browser.