Subversion Repositories HelenOS-historic

Rev

Rev 1160 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 1160 Rev 1398
Line 29... Line 29...
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
-
 
35
	
-
 
36
	# save R12 in SPRG1, backup CR in R12
-
 
37
	# save SP in SPRG2
-
 
38
 
-
 
39
	mtsprg1 r12
-
 
40
	mfcr r12
-
 
41
	mtsprg2 sp
-
 
42
	
-
 
43
	# check whether SP is in kernel
-
 
44
	
-
 
45
	andis. sp, sp, 0x8000
-
 
46
	bne 1f
-
 
47
	
-
 
48
		# stack is in user-space
-
 
49
		
-
 
50
		mfsprg0 sp
-
 
51
	
-
 
52
	b 2f
-
 
53
	
-
 
54
	1:
-
 
55
	
-
 
56
		# stack is in kernel
-
 
57
		
-
 
58
		mfsprg2 sp
-
 
59
		subis sp, sp, 0x8000
-
 
60
	
-
 
61
	2:
-
 
62
	
-
 
63
	subi sp, sp, 160
-
 
64
	stw r0, 8(sp)
-
 
65
	stw r2, 12(sp)
-
 
66
	stw r3, 16(sp)
-
 
67
	stw r4, 20(sp)
-
 
68
	stw r5, 24(sp)
-
 
69
	stw r6, 28(sp)
-
 
70
	stw r7, 32(sp)
-
 
71
	stw r8, 36(sp)
-
 
72
	stw r9, 40(sp)
-
 
73
	stw r10, 44(sp)
-
 
74
	stw r11, 48(sp)
-
 
75
	stw r13, 52(sp)
-
 
76
	stw r14, 56(sp)
-
 
77
	stw r15, 60(sp)
-
 
78
	stw r16, 64(sp)
-
 
79
	stw r17, 68(sp)
-
 
80
	stw r18, 72(sp)
-
 
81
	stw r19, 76(sp)
-
 
82
	stw r20, 80(sp)
-
 
83
	stw r21, 84(sp)
-
 
84
	stw r22, 88(sp)
-
 
85
	stw r23, 92(sp)
-
 
86
	stw r24, 96(sp)
-
 
87
	stw r25, 100(sp)
-
 
88
	stw r26, 104(sp)
-
 
89
	stw r27, 108(sp)
-
 
90
	stw r28, 112(sp)
-
 
91
	stw r29, 116(sp)
-
 
92
	stw r30, 120(sp)
-
 
93
	stw r31, 124(sp)
-
 
94
	
-
 
95
	stw r12, 128(sp)
-
 
96
	
-
 
97
	mfsrr0 r12
-
 
98
	stw r12, 132(sp)
-
 
99
	
-
 
100
	mfsrr1 r12
-
 
101
	stw r12, 136(sp)
-
 
102
	
-
 
103
	mflr r12
-
 
104
	stw r12, 140(sp)
-
 
105
	
-
 
106
	mfctr r12
-
 
107
	stw r12, 144(sp)
-
 
108
	
-
 
109
	mfxer r12
-
 
110
	stw r12, 148(sp)
-
 
111
	
-
 
112
	mfsprg1 r12
-
 
113
	stw r12, 152(sp)
-
 
114
	
-
 
115
	mfsprg2 r12
-
 
116
	stw r12, 156(sp)
-
 
117
.endm
-
 
118
 
-
 
119
.org 0x060
-
 
120
jump_to_kernel:
-
 
121
	lis r12, iret@ha
-
 
122
	addi r12, r12, iret@l
-
 
123
	mtlr r12
-
 
124
 
-
 
125
	mfmsr r12
-
 
126
	ori r12, r12, (msr_ir | msr_dr)@l
-
 
127
	mtsrr1 r12
-
 
128
	
-
 
129
	addis sp, sp, 0x8000
-
 
130
	mr r4, sp
-
 
131
	addi r4, r4, 8
-
 
132
	
-
 
133
	rfi
-
 
134
 
-
 
135
jump_to_kernel_syscall:
-
 
136
	lis r12, syscall_handler@ha
-
 
137
	addi r12, r12, syscall_handler@l
-
 
138
	mtsrr0 r12
-
 
139
	
-
 
140
	lis r12, iret_syscall@ha
-
 
141
	addi r12, r12, iret_syscall@l
-
 
142
	mtlr r12
-
 
143
 
-
 
144
	mfmsr r12
-
 
145
	ori r12, r12, (msr_ir | msr_dr)@l
-
 
146
	mtsrr1 r12
-
 
147
	
-
 
148
	addis sp, sp, 0x8000
-
 
149
	rfi
-
 
150
 
34
.org 0x100
151
.org 0x100
35
.global exc_system_reset
152
.global exc_system_reset
36
exc_system_reset:
153
exc_system_reset:
37
	b exc_system_reset
154
	b exc_system_reset
38
 
155
 
Line 42... Line 159...
42
	b exc_machine_check
159
	b exc_machine_check
43
 
160
 
44
.org 0x300
161
.org 0x300
45
.global exc_data_storage
162
.global exc_data_storage
46
exc_data_storage:
163
exc_data_storage:
47
	b exc_data_storage
164
	CONTEXT_STORE
48
 
165
	
49
.org 0x380
166
	lis r12, pht_refill@ha
50
.global exc_data_segment
167
	addi r12, r12, pht_refill@l
51
exc_data_segment:
168
	mtsrr0 r12
-
 
169
	
-
 
170
	li r3, 1
52
	b exc_data_segment
171
	b jump_to_kernel
53
 
172
 
54
.org 0x400
173
.org 0x400
55
.global exc_instruction_storage
174
.global exc_instruction_storage
56
exc_instruction_storage:
175
exc_instruction_storage:
57
	b exc_instruction_storage
176
	CONTEXT_STORE
58
 
177
	
59
.org 0x480
178
	lis r12, pht_refill@ha
60
.global exc_instruction_segment
179
	addi r12, r12, pht_refill@l
61
exc_instruction_segment:
180
	mtsrr0 r12
-
 
181
	
-
 
182
	li r3, 0
62
	b exc_instruction_segment
183
	b jump_to_kernel
63
 
184
 
64
.org 0x500
185
.org 0x500
65
.global exc_external
186
.global exc_external
66
exc_external:
187
exc_external:
67
	b exc_external
188
	b exc_external
Line 82... Line 203...
82
	b exc_fp_unavailable
203
	b exc_fp_unavailable
83
 
204
 
84
.org 0x900
205
.org 0x900
85
.global exc_decrementer
206
.global exc_decrementer
86
exc_decrementer:
207
exc_decrementer:
87
	mtspr sprg1, sp
-
 
88
	
-
 
89
	subis sp, sp, 0x8000
-
 
90
	
-
 
91
	subi sp, sp, 144
-
 
92
	stw r0, 0(sp)
-
 
93
	stw r2, 4(sp)
-
 
94
	stw r3, 8(sp)
208
	CONTEXT_STORE
95
	stw r4, 12(sp)
-
 
96
	stw r5, 16(sp)
-
 
97
	stw r6, 20(sp)
-
 
98
	stw r7, 24(sp)
-
 
99
	stw r8, 28(sp)
-
 
100
	stw r9, 32(sp)
-
 
101
	stw r10, 36(sp)
-
 
102
	stw r11, 40(sp)
-
 
103
	stw r12, 44(sp)
-
 
104
	stw r13, 48(sp)
-
 
105
	stw r14, 52(sp)
-
 
106
	stw r15, 56(sp)
-
 
107
	stw r16, 60(sp)
-
 
108
	stw r17, 64(sp)
-
 
109
	stw r18, 68(sp)
-
 
110
	stw r19, 72(sp)
-
 
111
	stw r20, 76(sp)
-
 
112
	stw r21, 80(sp)
-
 
113
	stw r22, 84(sp)
-
 
114
	stw r23, 88(sp)
-
 
115
	stw r24, 92(sp)
-
 
116
	stw r25, 96(sp)
-
 
117
	stw r26, 100(sp)
-
 
118
	stw r27, 104(sp)
-
 
119
	stw r28, 108(sp)
-
 
120
	stw r29, 112(sp)
-
 
121
	stw r30, 116(sp)
-
 
122
	stw r31, 120(sp)
-
 
123
	
-
 
124
	mfspr r3, srr0
-
 
125
	stw r3, 124(sp)
-
 
126
	
-
 
127
	mfspr r3, srr1
-
 
128
	stw r3, 128(sp)
-
 
129
	
-
 
130
	mflr r3
-
 
131
	stw r3, 132(sp)
-
 
132
	
-
 
133
	mfcr r3
-
 
134
	stw r3, 136(sp)
-
 
135
	
-
 
136
	mfctr r3
-
 
137
	stw r3, 140(sp)
-
 
138
	
-
 
139
	mfxer r3
-
 
140
	stw r3, 144(sp)
-
 
141
 
209
 
142
	lis r3, exc_dispatch@ha
210
	lis r12, exc_dispatch@ha
143
	addi r3, r3, exc_dispatch@l
211
	addi r12, r12, exc_dispatch@l
144
	mtspr srr0, r3
-
 
145
	
-
 
146
	mfmsr r3
-
 
147
	ori r3, r3, (msr_ir | msr_dr)@l
-
 
148
	mtspr srr1, r3
-
 
149
	
-
 
150
	lis r3, iret@ha
-
 
151
	addi r3, r3, iret@l
-
 
152
	mtlr r3
212
	mtsrr0 r12
153
	
213
	
154
	addis sp, sp, 0x8000
-
 
155
	li r3, 10
214
	li r3, 10
156
	rfid
215
	b jump_to_kernel
157
 
216
 
158
.org 0xa00
217
.org 0xa00
159
.global exc_reserved0
218
.global exc_reserved0
160
exc_reserved0:
219
exc_reserved0:
161
	b exc_reserved0
220
	b exc_reserved0
Line 166... Line 225...
166
	b exc_reserved1
225
	b exc_reserved1
167
 
226
 
168
.org 0xc00
227
.org 0xc00
169
.global exc_syscall
228
.global exc_syscall
170
exc_syscall:
229
exc_syscall:
-
 
230
	CONTEXT_STORE	
-
 
231
	
171
	b exc_syscall
232
	b jump_to_kernel_syscall
172
 
233
 
173
.org 0xd00
234
.org 0xd00
174
.global exc_trace
235
.global exc_trace
175
exc_trace:
236
exc_trace:
176
	b exc_trace
237
	b exc_trace