Subversion Repositories HelenOS-historic

Rev

Rev 1267 | Rev 1277 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1267 Rev 1269
1
#
1
#
2
# Copyright (C) 2006 Martin Decky
2
# Copyright (C) 2006 Martin Decky
3
# All rights reserved.
3
# All rights reserved.
4
#
4
#
5
# Redistribution and use in source and binary forms, with or without
5
# Redistribution and use in source and binary forms, with or without
6
# modification, are permitted provided that the following conditions
6
# modification, are permitted provided that the following conditions
7
# are met:
7
# are met:
8
#
8
#
9
# - Redistributions of source code must retain the above copyright
9
# - Redistributions of source code must retain the above copyright
10
#   notice, this list of conditions and the following disclaimer.
10
#   notice, this list of conditions and the following disclaimer.
11
# - Redistributions in binary form must reproduce the above copyright
11
# - Redistributions in binary form must reproduce the above copyright
12
#   notice, this list of conditions and the following disclaimer in the
12
#   notice, this list of conditions and the following disclaimer in the
13
#   documentation and/or other materials provided with the distribution.
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
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.
15
#   derived from this software without specific prior written permission.
16
#
16
#
17
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
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
18
# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
19
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
20
# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
21
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22
# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
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
23
# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24
# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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
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.
26
# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
#
27
#
28
 
28
 
29
#include <arch/asm/regname.h>
29
#include <arch/asm/regname.h>
30
#include <arch/mm/page.h>
30
#include <arch/mm/page.h>
31
 
31
 
32
.section K_UNMAPPED_TEXT_START, "ax"
32
.section K_UNMAPPED_TEXT_START, "ax"
33
 
33
 
34
.macro CONTEXT_STORE
34
.macro CONTEXT_STORE
35
	
35
	
36
	# save SP in SPRG1
36
	# save SP in SPRG1
37
	# save R12 in SPRG2, backup CR in R12
37
	# save R12 in SPRG2, backup CR in R12
38
 
38
 
39
	mtsprg1 sp
39
	mtsprg1 sp
40
	mtsprg2 r12
40
	mtsprg2 r12
41
	mfcr r12
41
	mfcr r12
42
	
42
	
43
	# check whether SP is in kernel
43
	# check whether SP is in kernel
44
	
44
	
45
	andis. sp, sp, 0x8000
45
	andis. sp, sp, 0x8000
46
	bne 1f
46
	bne 1f
47
	
47
	
48
		# stack is in user-space
48
		# stack is in user-space
49
		
49
		
50
		mfsprg0 sp
50
		mfsprg0 sp
51
	
51
	
52
	b 2f
52
	b 2f
53
	
53
	
54
	1:
54
	1:
55
	
55
	
56
		# stack is in kernel
56
		# stack is in kernel
57
		
57
		
58
		mfsprg1 sp
58
		mfsprg1 sp
59
		subis sp, sp, 0x8000
59
		subis sp, sp, 0x8000
60
	
60
	
61
	2:
61
	2:
62
	
62
	
63
	subi sp, sp, 140
63
	subi sp, sp, 140
64
	stw r0, 0(sp)
64
	stw r0, 0(sp)
65
	stw r2, 4(sp)
65
	stw r2, 4(sp)
66
	stw r3, 8(sp)
66
	stw r3, 8(sp)
67
	stw r4, 12(sp)
67
	stw r4, 12(sp)
68
	stw r5, 16(sp)
68
	stw r5, 16(sp)
69
	stw r6, 20(sp)
69
	stw r6, 20(sp)
70
	stw r7, 24(sp)
70
	stw r7, 24(sp)
71
	stw r8, 28(sp)
71
	stw r8, 28(sp)
72
	stw r9, 32(sp)
72
	stw r9, 32(sp)
73
	stw r10, 36(sp)
73
	stw r10, 36(sp)
74
	stw r11, 40(sp)
74
	stw r11, 40(sp)
75
	stw r13, 44(sp)
75
	stw r13, 44(sp)
76
	stw r14, 48(sp)
76
	stw r14, 48(sp)
77
	stw r15, 52(sp)
77
	stw r15, 52(sp)
78
	stw r16, 56(sp)
78
	stw r16, 56(sp)
79
	stw r17, 60(sp)
79
	stw r17, 60(sp)
80
	stw r18, 64(sp)
80
	stw r18, 64(sp)
81
	stw r19, 68(sp)
81
	stw r19, 68(sp)
82
	stw r20, 72(sp)
82
	stw r20, 72(sp)
83
	stw r21, 76(sp)
83
	stw r21, 76(sp)
84
	stw r22, 80(sp)
84
	stw r22, 80(sp)
85
	stw r23, 84(sp)
85
	stw r23, 84(sp)
86
	stw r24, 88(sp)
86
	stw r24, 88(sp)
87
	stw r25, 92(sp)
87
	stw r25, 92(sp)
88
	stw r26, 96(sp)
88
	stw r26, 96(sp)
89
	stw r27, 100(sp)
89
	stw r27, 100(sp)
90
	stw r28, 104(sp)
90
	stw r28, 104(sp)
91
	stw r29, 108(sp)
91
	stw r29, 108(sp)
92
	stw r30, 112(sp)
92
	stw r30, 112(sp)
93
	stw r31, 116(sp)
93
	stw r31, 116(sp)
94
	
94
	
95
	mfsrr0 r3
95
	mfsrr0 r3
96
	stw r3, 120(sp)
96
	stw r3, 120(sp)
97
	
97
	
98
	mfsrr1 r3
98
	mfsrr1 r3
99
	stw r3, 124(sp)
99
	stw r3, 124(sp)
100
	
100
	
101
	mflr r3
101
	mflr r3
102
	stw r3, 128(sp)
102
	stw r3, 128(sp)
103
	
103
	
104
	stw r12, 132(sp)
104
	stw r12, 132(sp)
105
	
105
	
106
	mfctr r3
106
	mfctr r3
107
	stw r3, 136(sp)
107
	stw r3, 136(sp)
108
	
108
	
109
	mfxer r3
109
	mfxer r3
110
	stw r3, 140(sp)
110
	stw r3, 140(sp)
111
.endm
111
.endm
112
 
112
 
113
.org 0x100
113
.org 0x100
114
.global exc_system_reset
114
.global exc_system_reset
115
exc_system_reset:
115
exc_system_reset:
116
	b exc_system_reset
116
	b exc_system_reset
117
 
117
 
118
.org 0x200
118
.org 0x200
119
.global exc_machine_check
119
.global exc_machine_check
120
exc_machine_check:
120
exc_machine_check:
121
	b exc_machine_check
121
	b exc_machine_check
122
 
122
 
123
.org 0x300
123
.org 0x300
124
.global exc_data_storage
124
.global exc_data_storage
125
exc_data_storage:
125
exc_data_storage:
126
	CONTEXT_STORE
126
	CONTEXT_STORE
127
	
127
	
128
	lis r3, pht_refill@ha
128
	lis r3, pht_refill@ha
129
	addi r3, r3, pht_refill@l
129
	addi r3, r3, pht_refill@l
130
	mtsrr0 r3
130
	mtsrr0 r3
131
	
131
	
132
	mfmsr r3
132
	mfmsr r3
133
	ori r3, r3, (msr_ir | msr_dr)@l
133
	ori r3, r3, (msr_ir | msr_dr)@l
134
	mtsrr1 r3
134
	mtsrr1 r3
135
	
135
	
136
	lis r3, iret@ha
136
	lis r3, iret@ha
137
	addi r3, r3, iret@l
137
	addi r3, r3, iret@l
138
	mtlr r3
138
	mtlr r3
139
	
139
	
140
	addis sp, sp, 0x8000
140
	addis sp, sp, 0x8000
-
 
141
	li r3, 1
141
	mr r3, sp
142
	mr r4, sp
142
	rfi
143
	rfi
143
 
144
 
144
.org 0x400
145
.org 0x400
145
.global exc_instruction_storage
146
.global exc_instruction_storage
146
exc_instruction_storage:
147
exc_instruction_storage:
147
	CONTEXT_STORE
148
	CONTEXT_STORE
148
	
149
	
149
	lis r3, pht_refill@ha
150
	lis r3, pht_refill@ha
150
	addi r3, r3, pht_refill@l
151
	addi r3, r3, pht_refill@l
151
	mtsrr0 r3
152
	mtsrr0 r3
152
	
153
	
153
	mfmsr r3
154
	mfmsr r3
154
	ori r3, r3, (msr_ir | msr_dr)@l
155
	ori r3, r3, (msr_ir | msr_dr)@l
155
	mtsrr1 r3
156
	mtsrr1 r3
156
	
157
	
157
	lis r3, iret@ha
158
	lis r3, iret@ha
158
	addi r3, r3, iret@l
159
	addi r3, r3, iret@l
159
	mtlr r3
160
	mtlr r3
160
	
161
	
161
	addis sp, sp, 0x8000
162
	addis sp, sp, 0x8000
-
 
163
	li r3, 0
162
	mr r3, sp
164
	mr r4, sp
163
	rfi
165
	rfi
164
 
166
 
165
.org 0x500
167
.org 0x500
166
.global exc_external
168
.global exc_external
167
exc_external:
169
exc_external:
168
	b exc_external
170
	b exc_external
169
 
171
 
170
.org 0x600
172
.org 0x600
171
.global exc_alignment
173
.global exc_alignment
172
exc_alignment:
174
exc_alignment:
173
	b exc_alignment
175
	b exc_alignment
174
 
176
 
175
.org 0x700
177
.org 0x700
176
.global exc_program
178
.global exc_program
177
exc_program:
179
exc_program:
178
	b exc_program
180
	b exc_program
179
 
181
 
180
.org 0x800
182
.org 0x800
181
.global exc_fp_unavailable
183
.global exc_fp_unavailable
182
exc_fp_unavailable:
184
exc_fp_unavailable:
183
	b exc_fp_unavailable
185
	b exc_fp_unavailable
184
 
186
 
185
.org 0x900
187
.org 0x900
186
.global exc_decrementer
188
.global exc_decrementer
187
exc_decrementer:
189
exc_decrementer:
188
	CONTEXT_STORE	
190
	CONTEXT_STORE	
189
 
191
 
190
	lis r3, exc_dispatch@ha
192
	lis r3, exc_dispatch@ha
191
	addi r3, r3, exc_dispatch@l
193
	addi r3, r3, exc_dispatch@l
192
	mtsrr0 r3
194
	mtsrr0 r3
193
	
195
	
194
	mfmsr r3
196
	mfmsr r3
195
	ori r3, r3, (msr_ir | msr_dr)@l
197
	ori r3, r3, (msr_ir | msr_dr)@l
196
	mtsrr1 r3
198
	mtsrr1 r3
197
	
199
	
198
	lis r3, iret@ha
200
	lis r3, iret@ha
199
	addi r3, r3, iret@l
201
	addi r3, r3, iret@l
200
	mtlr r3
202
	mtlr r3
201
	
203
	
202
	addis sp, sp, 0x8000
204
	addis sp, sp, 0x8000
203
	li r3, 10
205
	li r3, 10
204
	mr r4, sp
206
	mr r4, sp
205
	rfi
207
	rfi
206
 
208
 
207
.org 0xa00
209
.org 0xa00
208
.global exc_reserved0
210
.global exc_reserved0
209
exc_reserved0:
211
exc_reserved0:
210
	b exc_reserved0
212
	b exc_reserved0
211
 
213
 
212
.org 0xb00
214
.org 0xb00
213
.global exc_reserved1
215
.global exc_reserved1
214
exc_reserved1:
216
exc_reserved1:
215
	b exc_reserved1
217
	b exc_reserved1
216
 
218
 
217
.org 0xc00
219
.org 0xc00
218
.global exc_syscall
220
.global exc_syscall
219
exc_syscall:
221
exc_syscall:
220
	b exc_syscall
222
	b exc_syscall
221
 
223
 
222
.org 0xd00
224
.org 0xd00
223
.global exc_trace
225
.global exc_trace
224
exc_trace:
226
exc_trace:
225
	b exc_trace
227
	b exc_trace
226
 
228