Subversion Repositories HelenOS

Rev

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

Rev 1864 Rev 1865
1
#
1
#
2
# Copyright (C) 2005 Jakub Jermar
2
# Copyright (C) 2005 Jakub Jermar
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
/**
29
/**
-
 
30
 * @file
30
 * This file contains kernel trap table.
31
 * @brief This file contains kernel trap table.
31
 */
32
 */
32
 
33
 
33
.register %g2, #scratch
34
.register %g2, #scratch
34
.register %g3, #scratch
35
.register %g3, #scratch
35
 
36
 
36
.text
37
.text
37
 
38
 
38
#include <arch/trap/trap_table.h>
39
#include <arch/trap/trap_table.h>
39
#include <arch/trap/regwin.h>
40
#include <arch/trap/regwin.h>
40
#include <arch/trap/interrupt.h>
41
#include <arch/trap/interrupt.h>
41
#include <arch/trap/exception.h>
42
#include <arch/trap/exception.h>
42
#include <arch/trap/syscall.h>
43
#include <arch/trap/syscall.h>
43
#include <arch/trap/mmu.h>
44
#include <arch/trap/mmu.h>
44
#include <arch/mm/mmu.h>
45
#include <arch/mm/mmu.h>
45
#include <arch/mm/page.h>
46
#include <arch/mm/page.h>
46
#include <arch/stack.h>
47
#include <arch/stack.h>
47
#include <arch/regdef.h>
48
#include <arch/regdef.h>
48
 
49
 
49
#define TABLE_SIZE	TRAP_TABLE_SIZE
50
#define TABLE_SIZE	TRAP_TABLE_SIZE
50
#define ENTRY_SIZE	TRAP_TABLE_ENTRY_SIZE
51
#define ENTRY_SIZE	TRAP_TABLE_ENTRY_SIZE
51
 
52
 
52
/*
53
/*
53
 * Kernel trap table.
54
 * Kernel trap table.
54
 */
55
 */
55
.align TABLE_SIZE
56
.align TABLE_SIZE
56
.global trap_table
57
.global trap_table
57
trap_table:
58
trap_table:
58
 
59
 
59
/* TT = 0x08, TL = 0, instruction_access_exception */
60
/* TT = 0x08, TL = 0, instruction_access_exception */
60
.org trap_table + TT_INSTRUCTION_ACCESS_EXCEPTION*ENTRY_SIZE
61
.org trap_table + TT_INSTRUCTION_ACCESS_EXCEPTION*ENTRY_SIZE
61
.global instruction_access_exception
62
.global instruction_access_exception
62
instruction_access_exception:
63
instruction_access_exception:
63
	PREEMPTIBLE_HANDLER do_instruction_access_exc
64
	PREEMPTIBLE_HANDLER do_instruction_access_exc
64
 
65
 
65
/* TT = 0x10, TL = 0, illegal_instruction */
66
/* TT = 0x10, TL = 0, illegal_instruction */
66
.org trap_table + TT_ILLEGAL_INSTRUCTION*ENTRY_SIZE
67
.org trap_table + TT_ILLEGAL_INSTRUCTION*ENTRY_SIZE
67
.global illegal_instruction
68
.global illegal_instruction
68
illegal_instruction:
69
illegal_instruction:
69
	PREEMPTIBLE_HANDLER do_illegal_instruction
70
	PREEMPTIBLE_HANDLER do_illegal_instruction
70
 
71
 
71
/* TT = 0x24, TL = 0, clean_window handler */
72
/* TT = 0x24, TL = 0, clean_window handler */
72
.org trap_table + TT_CLEAN_WINDOW*ENTRY_SIZE
73
.org trap_table + TT_CLEAN_WINDOW*ENTRY_SIZE
73
.global clean_window_handler
74
.global clean_window_handler
74
clean_window_handler:
75
clean_window_handler:
75
	CLEAN_WINDOW_HANDLER
76
	CLEAN_WINDOW_HANDLER
76
 
77
 
77
/* TT = 0x32, TL = 0, data_access_error */
78
/* TT = 0x32, TL = 0, data_access_error */
78
.org trap_table + TT_DATA_ACCESS_ERROR*ENTRY_SIZE
79
.org trap_table + TT_DATA_ACCESS_ERROR*ENTRY_SIZE
79
.global data_access_error
80
.global data_access_error
80
data_access_error:
81
data_access_error:
81
	PREEMPTIBLE_HANDLER do_data_access_error
82
	PREEMPTIBLE_HANDLER do_data_access_error
82
 
83
 
83
/* TT = 0x34, TL = 0, mem_address_not_aligned */
84
/* TT = 0x34, TL = 0, mem_address_not_aligned */
84
.org trap_table + TT_MEM_ADDRESS_NOT_ALIGNED*ENTRY_SIZE
85
.org trap_table + TT_MEM_ADDRESS_NOT_ALIGNED*ENTRY_SIZE
85
.global mem_address_not_aligned
86
.global mem_address_not_aligned
86
mem_address_not_aligned:
87
mem_address_not_aligned:
87
	PREEMPTIBLE_HANDLER do_mem_address_not_aligned
88
	MEM_ADDRESS_NOT_ALIGNED_HANDLER
88
 
89
 
89
/* TT = 0x41, TL = 0, interrupt_level_1 handler */
90
/* TT = 0x41, TL = 0, interrupt_level_1 handler */
90
.org trap_table + TT_INTERRUPT_LEVEL_1*ENTRY_SIZE
91
.org trap_table + TT_INTERRUPT_LEVEL_1*ENTRY_SIZE
91
.global interrupt_level_1_handler
92
.global interrupt_level_1_handler
92
interrupt_level_1_handler:
93
interrupt_level_1_handler:
93
	INTERRUPT_LEVEL_N_HANDLER 1
94
	INTERRUPT_LEVEL_N_HANDLER 1
94
 
95
 
95
/* TT = 0x42, TL = 0, interrupt_level_2 handler */
96
/* TT = 0x42, TL = 0, interrupt_level_2 handler */
96
.org trap_table + TT_INTERRUPT_LEVEL_2*ENTRY_SIZE
97
.org trap_table + TT_INTERRUPT_LEVEL_2*ENTRY_SIZE
97
.global interrupt_level_2_handler
98
.global interrupt_level_2_handler
98
interrupt_level_2_handler:
99
interrupt_level_2_handler:
99
	INTERRUPT_LEVEL_N_HANDLER 2
100
	INTERRUPT_LEVEL_N_HANDLER 2
100
 
101
 
101
/* TT = 0x43, TL = 0, interrupt_level_3 handler */
102
/* TT = 0x43, TL = 0, interrupt_level_3 handler */
102
.org trap_table + TT_INTERRUPT_LEVEL_3*ENTRY_SIZE
103
.org trap_table + TT_INTERRUPT_LEVEL_3*ENTRY_SIZE
103
.global interrupt_level_3_handler
104
.global interrupt_level_3_handler
104
interrupt_level_3_handler:
105
interrupt_level_3_handler:
105
	INTERRUPT_LEVEL_N_HANDLER 3
106
	INTERRUPT_LEVEL_N_HANDLER 3
106
 
107
 
107
/* TT = 0x44, TL = 0, interrupt_level_4 handler */
108
/* TT = 0x44, TL = 0, interrupt_level_4 handler */
108
.org trap_table + TT_INTERRUPT_LEVEL_4*ENTRY_SIZE
109
.org trap_table + TT_INTERRUPT_LEVEL_4*ENTRY_SIZE
109
.global interrupt_level_4_handler
110
.global interrupt_level_4_handler
110
interrupt_level_4_handler:
111
interrupt_level_4_handler:
111
	INTERRUPT_LEVEL_N_HANDLER 4
112
	INTERRUPT_LEVEL_N_HANDLER 4
112
 
113
 
113
/* TT = 0x45, TL = 0, interrupt_level_5 handler */
114
/* TT = 0x45, TL = 0, interrupt_level_5 handler */
114
.org trap_table + TT_INTERRUPT_LEVEL_5*ENTRY_SIZE
115
.org trap_table + TT_INTERRUPT_LEVEL_5*ENTRY_SIZE
115
.global interrupt_level_5_handler
116
.global interrupt_level_5_handler
116
interrupt_level_5_handler:
117
interrupt_level_5_handler:
117
	INTERRUPT_LEVEL_N_HANDLER 5
118
	INTERRUPT_LEVEL_N_HANDLER 5
118
 
119
 
119
/* TT = 0x46, TL = 0, interrupt_level_6 handler */
120
/* TT = 0x46, TL = 0, interrupt_level_6 handler */
120
.org trap_table + TT_INTERRUPT_LEVEL_6*ENTRY_SIZE
121
.org trap_table + TT_INTERRUPT_LEVEL_6*ENTRY_SIZE
121
.global interrupt_level_6_handler
122
.global interrupt_level_6_handler
122
interrupt_level_6_handler:
123
interrupt_level_6_handler:
123
	INTERRUPT_LEVEL_N_HANDLER 6
124
	INTERRUPT_LEVEL_N_HANDLER 6
124
 
125
 
125
/* TT = 0x47, TL = 0, interrupt_level_7 handler */
126
/* TT = 0x47, TL = 0, interrupt_level_7 handler */
126
.org trap_table + TT_INTERRUPT_LEVEL_7*ENTRY_SIZE
127
.org trap_table + TT_INTERRUPT_LEVEL_7*ENTRY_SIZE
127
.global interrupt_level_7_handler
128
.global interrupt_level_7_handler
128
interrupt_level_7_handler:
129
interrupt_level_7_handler:
129
	INTERRUPT_LEVEL_N_HANDLER 7
130
	INTERRUPT_LEVEL_N_HANDLER 7
130
 
131
 
131
/* TT = 0x48, TL = 0, interrupt_level_8 handler */
132
/* TT = 0x48, TL = 0, interrupt_level_8 handler */
132
.org trap_table + TT_INTERRUPT_LEVEL_8*ENTRY_SIZE
133
.org trap_table + TT_INTERRUPT_LEVEL_8*ENTRY_SIZE
133
.global interrupt_level_8_handler
134
.global interrupt_level_8_handler
134
interrupt_level_8_handler:
135
interrupt_level_8_handler:
135
	INTERRUPT_LEVEL_N_HANDLER 8
136
	INTERRUPT_LEVEL_N_HANDLER 8
136
 
137
 
137
/* TT = 0x49, TL = 0, interrupt_level_9 handler */
138
/* TT = 0x49, TL = 0, interrupt_level_9 handler */
138
.org trap_table + TT_INTERRUPT_LEVEL_9*ENTRY_SIZE
139
.org trap_table + TT_INTERRUPT_LEVEL_9*ENTRY_SIZE
139
.global interrupt_level_9_handler
140
.global interrupt_level_9_handler
140
interrupt_level_9_handler:
141
interrupt_level_9_handler:
141
	INTERRUPT_LEVEL_N_HANDLER 9
142
	INTERRUPT_LEVEL_N_HANDLER 9
142
 
143
 
143
/* TT = 0x4a, TL = 0, interrupt_level_10 handler */
144
/* TT = 0x4a, TL = 0, interrupt_level_10 handler */
144
.org trap_table + TT_INTERRUPT_LEVEL_10*ENTRY_SIZE
145
.org trap_table + TT_INTERRUPT_LEVEL_10*ENTRY_SIZE
145
.global interrupt_level_10_handler
146
.global interrupt_level_10_handler
146
interrupt_level_10_handler:
147
interrupt_level_10_handler:
147
	INTERRUPT_LEVEL_N_HANDLER 10
148
	INTERRUPT_LEVEL_N_HANDLER 10
148
 
149
 
149
/* TT = 0x4b, TL = 0, interrupt_level_11 handler */
150
/* TT = 0x4b, TL = 0, interrupt_level_11 handler */
150
.org trap_table + TT_INTERRUPT_LEVEL_11*ENTRY_SIZE
151
.org trap_table + TT_INTERRUPT_LEVEL_11*ENTRY_SIZE
151
.global interrupt_level_11_handler
152
.global interrupt_level_11_handler
152
interrupt_level_11_handler:
153
interrupt_level_11_handler:
153
	INTERRUPT_LEVEL_N_HANDLER 11
154
	INTERRUPT_LEVEL_N_HANDLER 11
154
 
155
 
155
/* TT = 0x4c, TL = 0, interrupt_level_12 handler */
156
/* TT = 0x4c, TL = 0, interrupt_level_12 handler */
156
.org trap_table + TT_INTERRUPT_LEVEL_12*ENTRY_SIZE
157
.org trap_table + TT_INTERRUPT_LEVEL_12*ENTRY_SIZE
157
.global interrupt_level_12_handler
158
.global interrupt_level_12_handler
158
interrupt_level_12_handler:
159
interrupt_level_12_handler:
159
	INTERRUPT_LEVEL_N_HANDLER 12
160
	INTERRUPT_LEVEL_N_HANDLER 12
160
 
161
 
161
/* TT = 0x4d, TL = 0, interrupt_level_13 handler */
162
/* TT = 0x4d, TL = 0, interrupt_level_13 handler */
162
.org trap_table + TT_INTERRUPT_LEVEL_13*ENTRY_SIZE
163
.org trap_table + TT_INTERRUPT_LEVEL_13*ENTRY_SIZE
163
.global interrupt_level_13_handler
164
.global interrupt_level_13_handler
164
interrupt_level_13_handler:
165
interrupt_level_13_handler:
165
	INTERRUPT_LEVEL_N_HANDLER 13
166
	INTERRUPT_LEVEL_N_HANDLER 13
166
 
167
 
167
/* TT = 0x4e, TL = 0, interrupt_level_14 handler */
168
/* TT = 0x4e, TL = 0, interrupt_level_14 handler */
168
.org trap_table + TT_INTERRUPT_LEVEL_14*ENTRY_SIZE
169
.org trap_table + TT_INTERRUPT_LEVEL_14*ENTRY_SIZE
169
.global interrupt_level_14_handler
170
.global interrupt_level_14_handler
170
interrupt_level_14_handler:
171
interrupt_level_14_handler:
171
	INTERRUPT_LEVEL_N_HANDLER 14
172
	INTERRUPT_LEVEL_N_HANDLER 14
172
 
173
 
173
/* TT = 0x4f, TL = 0, interrupt_level_15 handler */
174
/* TT = 0x4f, TL = 0, interrupt_level_15 handler */
174
.org trap_table + TT_INTERRUPT_LEVEL_15*ENTRY_SIZE
175
.org trap_table + TT_INTERRUPT_LEVEL_15*ENTRY_SIZE
175
.global interrupt_level_15_handler
176
.global interrupt_level_15_handler
176
interrupt_level_15_handler:
177
interrupt_level_15_handler:
177
	INTERRUPT_LEVEL_N_HANDLER 15
178
	INTERRUPT_LEVEL_N_HANDLER 15
178
 
179
 
179
/* TT = 0x60, TL = 0, interrupt_vector_trap handler */
180
/* TT = 0x60, TL = 0, interrupt_vector_trap handler */
180
.org trap_table + TT_INTERRUPT_VECTOR_TRAP*ENTRY_SIZE
181
.org trap_table + TT_INTERRUPT_VECTOR_TRAP*ENTRY_SIZE
181
.global interrupt_vector_trap_handler
182
.global interrupt_vector_trap_handler
182
interrupt_vector_trap_handler:
183
interrupt_vector_trap_handler:
183
	INTERRUPT_VECTOR_TRAP_HANDLER
184
	INTERRUPT_VECTOR_TRAP_HANDLER
184
 
185
 
185
/* TT = 0x64, TL = 0, fast_instruction_access_MMU_miss */
186
/* TT = 0x64, TL = 0, fast_instruction_access_MMU_miss */
186
.org trap_table + TT_FAST_INSTRUCTION_ACCESS_MMU_MISS*ENTRY_SIZE
187
.org trap_table + TT_FAST_INSTRUCTION_ACCESS_MMU_MISS*ENTRY_SIZE
187
.global fast_instruction_access_mmu_miss_handler
188
.global fast_instruction_access_mmu_miss_handler
188
fast_instruction_access_mmu_miss_handler:
189
fast_instruction_access_mmu_miss_handler:
189
	FAST_INSTRUCTION_ACCESS_MMU_MISS_HANDLER
190
	FAST_INSTRUCTION_ACCESS_MMU_MISS_HANDLER
190
 
191
 
191
/* TT = 0x68, TL = 0, fast_data_access_MMU_miss */
192
/* TT = 0x68, TL = 0, fast_data_access_MMU_miss */
192
.org trap_table + TT_FAST_DATA_ACCESS_MMU_MISS*ENTRY_SIZE
193
.org trap_table + TT_FAST_DATA_ACCESS_MMU_MISS*ENTRY_SIZE
193
.global fast_data_access_mmu_miss_handler
194
.global fast_data_access_mmu_miss_handler
194
fast_data_access_mmu_miss_handler:
195
fast_data_access_mmu_miss_handler:
195
	FAST_DATA_ACCESS_MMU_MISS_HANDLER
196
	FAST_DATA_ACCESS_MMU_MISS_HANDLER
196
 
197
 
197
/* TT = 0x6c, TL = 0, fast_data_access_protection */
198
/* TT = 0x6c, TL = 0, fast_data_access_protection */
198
.org trap_table + TT_FAST_DATA_ACCESS_PROTECTION*ENTRY_SIZE
199
.org trap_table + TT_FAST_DATA_ACCESS_PROTECTION*ENTRY_SIZE
199
.global fast_data_access_protection_handler
200
.global fast_data_access_protection_handler
200
fast_data_access_protection_handler:
201
fast_data_access_protection_handler:
201
	FAST_DATA_ACCESS_PROTECTION_HANDLER
202
	FAST_DATA_ACCESS_PROTECTION_HANDLER
202
 
203
 
203
/* TT = 0x80, TL = 0, spill_0_normal handler */
204
/* TT = 0x80, TL = 0, spill_0_normal handler */
204
.org trap_table + TT_SPILL_0_NORMAL*ENTRY_SIZE
205
.org trap_table + TT_SPILL_0_NORMAL*ENTRY_SIZE
205
.global spill_0_normal
206
.global spill_0_normal
206
spill_0_normal:
207
spill_0_normal:
207
	SPILL_NORMAL_HANDLER_KERNEL
208
	SPILL_NORMAL_HANDLER_KERNEL
208
 
209
 
209
/* TT = 0x84, TL = 0, spill_1_normal handler */
210
/* TT = 0x84, TL = 0, spill_1_normal handler */
210
.org trap_table + TT_SPILL_1_NORMAL*ENTRY_SIZE
211
.org trap_table + TT_SPILL_1_NORMAL*ENTRY_SIZE
211
.global spill_1_normal
212
.global spill_1_normal
212
spill_1_normal:
213
spill_1_normal:
213
	SPILL_NORMAL_HANDLER_USERSPACE
214
	SPILL_NORMAL_HANDLER_USERSPACE
214
 
215
 
215
/* TT = 0x88, TL = 0, spill_2_normal handler */
216
/* TT = 0x88, TL = 0, spill_2_normal handler */
216
.org trap_table + TT_SPILL_2_NORMAL*ENTRY_SIZE
217
.org trap_table + TT_SPILL_2_NORMAL*ENTRY_SIZE
217
.global spill_2_normal
218
.global spill_2_normal
218
spill_2_normal:
219
spill_2_normal:
219
	SPILL_TO_USPACE_WINDOW_BUFFER
220
	SPILL_TO_USPACE_WINDOW_BUFFER
220
 
221
 
221
/* TT = 0xa0, TL = 0, spill_0_other handler */
222
/* TT = 0xa0, TL = 0, spill_0_other handler */
222
.org trap_table + TT_SPILL_0_OTHER*ENTRY_SIZE
223
.org trap_table + TT_SPILL_0_OTHER*ENTRY_SIZE
223
.global spill_0_other
224
.global spill_0_other
224
spill_0_other:
225
spill_0_other:
225
	SPILL_TO_USPACE_WINDOW_BUFFER
226
	SPILL_TO_USPACE_WINDOW_BUFFER
226
 
227
 
227
/* TT = 0xc0, TL = 0, fill_0_normal handler */
228
/* TT = 0xc0, TL = 0, fill_0_normal handler */
228
.org trap_table + TT_FILL_0_NORMAL*ENTRY_SIZE
229
.org trap_table + TT_FILL_0_NORMAL*ENTRY_SIZE
229
.global fill_0_normal
230
.global fill_0_normal
230
fill_0_normal:
231
fill_0_normal:
231
	FILL_NORMAL_HANDLER_KERNEL
232
	FILL_NORMAL_HANDLER_KERNEL
232
 
233
 
233
/* TT = 0xc4, TL = 0, fill_1_normal handler */
234
/* TT = 0xc4, TL = 0, fill_1_normal handler */
234
.org trap_table + TT_FILL_1_NORMAL*ENTRY_SIZE
235
.org trap_table + TT_FILL_1_NORMAL*ENTRY_SIZE
235
.global fill_1_normal
236
.global fill_1_normal
236
fill_1_normal:
237
fill_1_normal:
237
	FILL_NORMAL_HANDLER_USERSPACE
238
	FILL_NORMAL_HANDLER_USERSPACE
238
 
239
 
239
/* TT = 0x100, TL = 0, trap_instruction_0 */
240
/* TT = 0x100, TL = 0, trap_instruction_0 */
240
.org trap_table + TT_TRAP_INSTRUCTION(0)*ENTRY_SIZE
241
.org trap_table + TT_TRAP_INSTRUCTION(0)*ENTRY_SIZE
241
.global trap_instruction_0
242
.global trap_instruction_0
242
trap_instruction_0:
243
trap_instruction_0:
243
	TRAP_INSTRUCTION 0
244
	TRAP_INSTRUCTION 0
244
 
245
 
245
/* TT = 0x101, TL = 0, trap_instruction_1 */
246
/* TT = 0x101, TL = 0, trap_instruction_1 */
246
.org trap_table + TT_TRAP_INSTRUCTION(1)*ENTRY_SIZE
247
.org trap_table + TT_TRAP_INSTRUCTION(1)*ENTRY_SIZE
247
.global trap_instruction_1
248
.global trap_instruction_1
248
trap_instruction_1:
249
trap_instruction_1:
249
	TRAP_INSTRUCTION 1
250
	TRAP_INSTRUCTION 1
250
 
251
 
251
/* TT = 0x102, TL = 0, trap_instruction_2 */
252
/* TT = 0x102, TL = 0, trap_instruction_2 */
252
.org trap_table + TT_TRAP_INSTRUCTION(2)*ENTRY_SIZE
253
.org trap_table + TT_TRAP_INSTRUCTION(2)*ENTRY_SIZE
253
.global trap_instruction_2
254
.global trap_instruction_2
254
trap_instruction_2:
255
trap_instruction_2:
255
	TRAP_INSTRUCTION 2
256
	TRAP_INSTRUCTION 2
256
 
257
 
257
/* TT = 0x103, TL = 0, trap_instruction_3 */
258
/* TT = 0x103, TL = 0, trap_instruction_3 */
258
.org trap_table + TT_TRAP_INSTRUCTION(3)*ENTRY_SIZE
259
.org trap_table + TT_TRAP_INSTRUCTION(3)*ENTRY_SIZE
259
.global trap_instruction_3
260
.global trap_instruction_3
260
trap_instruction_3:
261
trap_instruction_3:
261
	TRAP_INSTRUCTION 3
262
	TRAP_INSTRUCTION 3
262
 
263
 
263
/* TT = 0x104, TL = 0, trap_instruction_4 */
264
/* TT = 0x104, TL = 0, trap_instruction_4 */
264
.org trap_table + TT_TRAP_INSTRUCTION(4)*ENTRY_SIZE
265
.org trap_table + TT_TRAP_INSTRUCTION(4)*ENTRY_SIZE
265
.global trap_instruction_4
266
.global trap_instruction_4
266
trap_instruction_4:
267
trap_instruction_4:
267
	TRAP_INSTRUCTION 4
268
	TRAP_INSTRUCTION 4
268
 
269
 
269
/* TT = 0x105, TL = 0, trap_instruction_5 */
270
/* TT = 0x105, TL = 0, trap_instruction_5 */
270
.org trap_table + TT_TRAP_INSTRUCTION(5)*ENTRY_SIZE
271
.org trap_table + TT_TRAP_INSTRUCTION(5)*ENTRY_SIZE
271
.global trap_instruction_5
272
.global trap_instruction_5
272
trap_instruction_5:
273
trap_instruction_5:
273
	TRAP_INSTRUCTION 5
274
	TRAP_INSTRUCTION 5
274
 
275
 
275
/* TT = 0x106, TL = 0, trap_instruction_6 */
276
/* TT = 0x106, TL = 0, trap_instruction_6 */
276
.org trap_table + TT_TRAP_INSTRUCTION(6)*ENTRY_SIZE
277
.org trap_table + TT_TRAP_INSTRUCTION(6)*ENTRY_SIZE
277
.global trap_instruction_6
278
.global trap_instruction_6
278
trap_instruction_6:
279
trap_instruction_6:
279
	TRAP_INSTRUCTION 6
280
	TRAP_INSTRUCTION 6
280
 
281
 
281
/* TT = 0x107, TL = 0, trap_instruction_7 */
282
/* TT = 0x107, TL = 0, trap_instruction_7 */
282
.org trap_table + TT_TRAP_INSTRUCTION(7)*ENTRY_SIZE
283
.org trap_table + TT_TRAP_INSTRUCTION(7)*ENTRY_SIZE
283
.global trap_instruction_7
284
.global trap_instruction_7
284
trap_instruction_7:
285
trap_instruction_7:
285
	TRAP_INSTRUCTION 7
286
	TRAP_INSTRUCTION 7
286
 
287
 
287
/* TT = 0x108, TL = 0, trap_instruction_8 */
288
/* TT = 0x108, TL = 0, trap_instruction_8 */
288
.org trap_table + TT_TRAP_INSTRUCTION(8)*ENTRY_SIZE
289
.org trap_table + TT_TRAP_INSTRUCTION(8)*ENTRY_SIZE
289
.global trap_instruction_8
290
.global trap_instruction_8
290
trap_instruction_8:
291
trap_instruction_8:
291
	TRAP_INSTRUCTION 8
292
	TRAP_INSTRUCTION 8
292
 
293
 
293
/* TT = 0x109, TL = 0, trap_instruction_9 */
294
/* TT = 0x109, TL = 0, trap_instruction_9 */
294
.org trap_table + TT_TRAP_INSTRUCTION(9)*ENTRY_SIZE
295
.org trap_table + TT_TRAP_INSTRUCTION(9)*ENTRY_SIZE
295
.global trap_instruction_9
296
.global trap_instruction_9
296
trap_instruction_9:
297
trap_instruction_9:
297
	TRAP_INSTRUCTION 9
298
	TRAP_INSTRUCTION 9
298
 
299
 
299
/* TT = 0x10a, TL = 0, trap_instruction_10 */
300
/* TT = 0x10a, TL = 0, trap_instruction_10 */
300
.org trap_table + TT_TRAP_INSTRUCTION(10)*ENTRY_SIZE
301
.org trap_table + TT_TRAP_INSTRUCTION(10)*ENTRY_SIZE
301
.global trap_instruction_10
302
.global trap_instruction_10
302
trap_instruction_10:
303
trap_instruction_10:
303
	TRAP_INSTRUCTION 10
304
	TRAP_INSTRUCTION 10
304
 
305
 
305
/* TT = 0x10b, TL = 0, trap_instruction_11 */
306
/* TT = 0x10b, TL = 0, trap_instruction_11 */
306
.org trap_table + TT_TRAP_INSTRUCTION(11)*ENTRY_SIZE
307
.org trap_table + TT_TRAP_INSTRUCTION(11)*ENTRY_SIZE
307
.global trap_instruction_11
308
.global trap_instruction_11
308
trap_instruction_11:
309
trap_instruction_11:
309
	TRAP_INSTRUCTION 11
310
	TRAP_INSTRUCTION 11
310
 
311
 
311
/* TT = 0x10c, TL = 0, trap_instruction_12 */
312
/* TT = 0x10c, TL = 0, trap_instruction_12 */
312
.org trap_table + TT_TRAP_INSTRUCTION(12)*ENTRY_SIZE
313
.org trap_table + TT_TRAP_INSTRUCTION(12)*ENTRY_SIZE
313
.global trap_instruction_12
314
.global trap_instruction_12
314
trap_instruction_12:
315
trap_instruction_12:
315
	TRAP_INSTRUCTION 12
316
	TRAP_INSTRUCTION 12
316
 
317
 
317
/* TT = 0x10d, TL = 0, trap_instruction_13 */
318
/* TT = 0x10d, TL = 0, trap_instruction_13 */
318
.org trap_table + TT_TRAP_INSTRUCTION(13)*ENTRY_SIZE
319
.org trap_table + TT_TRAP_INSTRUCTION(13)*ENTRY_SIZE
319
.global trap_instruction_13
320
.global trap_instruction_13
320
trap_instruction_13:
321
trap_instruction_13:
321
	TRAP_INSTRUCTION 13
322
	TRAP_INSTRUCTION 13
322
 
323
 
323
/* TT = 0x10e, TL = 0, trap_instruction_14 */
324
/* TT = 0x10e, TL = 0, trap_instruction_14 */
324
.org trap_table + TT_TRAP_INSTRUCTION(14)*ENTRY_SIZE
325
.org trap_table + TT_TRAP_INSTRUCTION(14)*ENTRY_SIZE
325
.global trap_instruction_14
326
.global trap_instruction_14
326
trap_instruction_14:
327
trap_instruction_14:
327
	TRAP_INSTRUCTION 14
328
	TRAP_INSTRUCTION 14
328
 
329
 
329
/* TT = 0x10f, TL = 0, trap_instruction_15 */
330
/* TT = 0x10f, TL = 0, trap_instruction_15 */
330
.org trap_table + TT_TRAP_INSTRUCTION(15)*ENTRY_SIZE
331
.org trap_table + TT_TRAP_INSTRUCTION(15)*ENTRY_SIZE
331
.global trap_instruction_15
332
.global trap_instruction_15
332
trap_instruction_15:
333
trap_instruction_15:
333
	TRAP_INSTRUCTION 15
334
	TRAP_INSTRUCTION 15
334
 
335
 
335
/* TT = 0x110, TL = 0, trap_instruction_16 */
336
/* TT = 0x110, TL = 0, trap_instruction_16 */
336
.org trap_table + TT_TRAP_INSTRUCTION(16)*ENTRY_SIZE
337
.org trap_table + TT_TRAP_INSTRUCTION(16)*ENTRY_SIZE
337
.global trap_instruction_16
338
.global trap_instruction_16
338
trap_instruction_16:
339
trap_instruction_16:
339
	TRAP_INSTRUCTION 16
340
	TRAP_INSTRUCTION 16
340
 
341
 
341
/* TT = 0x111, TL = 0, trap_instruction_17 */
342
/* TT = 0x111, TL = 0, trap_instruction_17 */
342
.org trap_table + TT_TRAP_INSTRUCTION(17)*ENTRY_SIZE
343
.org trap_table + TT_TRAP_INSTRUCTION(17)*ENTRY_SIZE
343
.global trap_instruction_17
344
.global trap_instruction_17
344
trap_instruction_17:
345
trap_instruction_17:
345
	TRAP_INSTRUCTION 17
346
	TRAP_INSTRUCTION 17
346
 
347
 
347
/* TT = 0x112, TL = 0, trap_instruction_18 */
348
/* TT = 0x112, TL = 0, trap_instruction_18 */
348
.org trap_table + TT_TRAP_INSTRUCTION(18)*ENTRY_SIZE
349
.org trap_table + TT_TRAP_INSTRUCTION(18)*ENTRY_SIZE
349
.global trap_instruction_18
350
.global trap_instruction_18
350
trap_instruction_18:
351
trap_instruction_18:
351
	TRAP_INSTRUCTION 18
352
	TRAP_INSTRUCTION 18
352
 
353
 
353
/* TT = 0x113, TL = 0, trap_instruction_19 */
354
/* TT = 0x113, TL = 0, trap_instruction_19 */
354
.org trap_table + TT_TRAP_INSTRUCTION(19)*ENTRY_SIZE
355
.org trap_table + TT_TRAP_INSTRUCTION(19)*ENTRY_SIZE
355
.global trap_instruction_19
356
.global trap_instruction_19
356
trap_instruction_19:
357
trap_instruction_19:
357
	TRAP_INSTRUCTION 19
358
	TRAP_INSTRUCTION 19
358
 
359
 
359
/* TT = 0x114, TL = 0, trap_instruction_20 */
360
/* TT = 0x114, TL = 0, trap_instruction_20 */
360
.org trap_table + TT_TRAP_INSTRUCTION(20)*ENTRY_SIZE
361
.org trap_table + TT_TRAP_INSTRUCTION(20)*ENTRY_SIZE
361
.global trap_instruction_20
362
.global trap_instruction_20
362
trap_instruction_20:
363
trap_instruction_20:
363
	TRAP_INSTRUCTION 20
364
	TRAP_INSTRUCTION 20
364
 
365
 
365
/* TT = 0x115, TL = 0, trap_instruction_21 */
366
/* TT = 0x115, TL = 0, trap_instruction_21 */
366
.org trap_table + TT_TRAP_INSTRUCTION(21)*ENTRY_SIZE
367
.org trap_table + TT_TRAP_INSTRUCTION(21)*ENTRY_SIZE
367
.global trap_instruction_21
368
.global trap_instruction_21
368
trap_instruction_21:
369
trap_instruction_21:
369
	TRAP_INSTRUCTION 21
370
	TRAP_INSTRUCTION 21
370
 
371
 
371
/* TT = 0x116, TL = 0, trap_instruction_22 */
372
/* TT = 0x116, TL = 0, trap_instruction_22 */
372
.org trap_table + TT_TRAP_INSTRUCTION(22)*ENTRY_SIZE
373
.org trap_table + TT_TRAP_INSTRUCTION(22)*ENTRY_SIZE
373
.global trap_instruction_22
374
.global trap_instruction_22
374
trap_instruction_22:
375
trap_instruction_22:
375
	TRAP_INSTRUCTION 22
376
	TRAP_INSTRUCTION 22
376
 
377
 
377
/* TT = 0x117, TL = 0, trap_instruction_23 */
378
/* TT = 0x117, TL = 0, trap_instruction_23 */
378
.org trap_table + TT_TRAP_INSTRUCTION(23)*ENTRY_SIZE
379
.org trap_table + TT_TRAP_INSTRUCTION(23)*ENTRY_SIZE
379
.global trap_instruction_23
380
.global trap_instruction_23
380
trap_instruction_23:
381
trap_instruction_23:
381
	TRAP_INSTRUCTION 23
382
	TRAP_INSTRUCTION 23
382
 
383
 
383
/* TT = 0x118, TL = 0, trap_instruction_24 */
384
/* TT = 0x118, TL = 0, trap_instruction_24 */
384
.org trap_table + TT_TRAP_INSTRUCTION(24)*ENTRY_SIZE
385
.org trap_table + TT_TRAP_INSTRUCTION(24)*ENTRY_SIZE
385
.global trap_instruction_24
386
.global trap_instruction_24
386
trap_instruction_24:
387
trap_instruction_24:
387
	TRAP_INSTRUCTION 24
388
	TRAP_INSTRUCTION 24
388
 
389
 
389
/* TT = 0x119, TL = 0, trap_instruction_25 */
390
/* TT = 0x119, TL = 0, trap_instruction_25 */
390
.org trap_table + TT_TRAP_INSTRUCTION(25)*ENTRY_SIZE
391
.org trap_table + TT_TRAP_INSTRUCTION(25)*ENTRY_SIZE
391
.global trap_instruction_25
392
.global trap_instruction_25
392
trap_instruction_25:
393
trap_instruction_25:
393
	TRAP_INSTRUCTION 25
394
	TRAP_INSTRUCTION 25
394
 
395
 
395
/* TT = 0x11a, TL = 0, trap_instruction_26 */
396
/* TT = 0x11a, TL = 0, trap_instruction_26 */
396
.org trap_table + TT_TRAP_INSTRUCTION(26)*ENTRY_SIZE
397
.org trap_table + TT_TRAP_INSTRUCTION(26)*ENTRY_SIZE
397
.global trap_instruction_26
398
.global trap_instruction_26
398
trap_instruction_26:
399
trap_instruction_26:
399
	TRAP_INSTRUCTION 26
400
	TRAP_INSTRUCTION 26
400
 
401
 
401
/* TT = 0x11b, TL = 0, trap_instruction_27 */
402
/* TT = 0x11b, TL = 0, trap_instruction_27 */
402
.org trap_table + TT_TRAP_INSTRUCTION(27)*ENTRY_SIZE
403
.org trap_table + TT_TRAP_INSTRUCTION(27)*ENTRY_SIZE
403
.global trap_instruction_27
404
.global trap_instruction_27
404
trap_instruction_27:
405
trap_instruction_27:
405
	TRAP_INSTRUCTION 27
406
	TRAP_INSTRUCTION 27
406
 
407
 
407
/* TT = 0x11c, TL = 0, trap_instruction_28 */
408
/* TT = 0x11c, TL = 0, trap_instruction_28 */
408
.org trap_table + TT_TRAP_INSTRUCTION(28)*ENTRY_SIZE
409
.org trap_table + TT_TRAP_INSTRUCTION(28)*ENTRY_SIZE
409
.global trap_instruction_28
410
.global trap_instruction_28
410
trap_instruction_28:
411
trap_instruction_28:
411
	TRAP_INSTRUCTION 28
412
	TRAP_INSTRUCTION 28
412
 
413
 
413
/* TT = 0x11d, TL = 0, trap_instruction_29 */
414
/* TT = 0x11d, TL = 0, trap_instruction_29 */
414
.org trap_table + TT_TRAP_INSTRUCTION(29)*ENTRY_SIZE
415
.org trap_table + TT_TRAP_INSTRUCTION(29)*ENTRY_SIZE
415
.global trap_instruction_29
416
.global trap_instruction_29
416
trap_instruction_29:
417
trap_instruction_29:
417
	TRAP_INSTRUCTION 29
418
	TRAP_INSTRUCTION 29
418
 
419
 
419
/* TT = 0x11e, TL = 0, trap_instruction_30 */
420
/* TT = 0x11e, TL = 0, trap_instruction_30 */
420
.org trap_table + TT_TRAP_INSTRUCTION(30)*ENTRY_SIZE
421
.org trap_table + TT_TRAP_INSTRUCTION(30)*ENTRY_SIZE
421
.global trap_instruction_30
422
.global trap_instruction_30
422
trap_instruction_30:
423
trap_instruction_30:
423
	TRAP_INSTRUCTION 30
424
	TRAP_INSTRUCTION 30
424
 
425
 
425
/* TT = 0x11f, TL = 0, trap_instruction_31 */
426
/* TT = 0x11f, TL = 0, trap_instruction_31 */
426
.org trap_table + TT_TRAP_INSTRUCTION(31)*ENTRY_SIZE
427
.org trap_table + TT_TRAP_INSTRUCTION(31)*ENTRY_SIZE
427
.global trap_instruction_31
428
.global trap_instruction_31
428
trap_instruction_31:
429
trap_instruction_31:
429
	TRAP_INSTRUCTION 31
430
	TRAP_INSTRUCTION 31
430
 
431
 
431
/*
432
/*
432
 * Handlers for TL>0.
433
 * Handlers for TL>0.
433
 */
434
 */
434
 
435
 
435
/* TT = 0x08, TL > 0, instruction_access_exception */
436
/* TT = 0x08, TL > 0, instruction_access_exception */
436
.org trap_table + (TT_INSTRUCTION_ACCESS_EXCEPTION+512)*ENTRY_SIZE
437
.org trap_table + (TT_INSTRUCTION_ACCESS_EXCEPTION+512)*ENTRY_SIZE
437
.global instruction_access_exception_high
438
.global instruction_access_exception_high
438
instruction_access_exception_high:
439
instruction_access_exception_high:
439
	PREEMPTIBLE_HANDLER do_instruction_access_exc
440
	PREEMPTIBLE_HANDLER do_instruction_access_exc
440
 
441
 
441
/* TT = 0x10, TL > 0, illegal_instruction */
442
/* TT = 0x10, TL > 0, illegal_instruction */
442
.org trap_table + (TT_ILLEGAL_INSTRUCTION+512)*ENTRY_SIZE
443
.org trap_table + (TT_ILLEGAL_INSTRUCTION+512)*ENTRY_SIZE
443
.global illegal_instruction_high
444
.global illegal_instruction_high
444
illegal_instruction_high:
445
illegal_instruction_high:
445
	PREEMPTIBLE_HANDLER do_illegal_instruction
446
	PREEMPTIBLE_HANDLER do_illegal_instruction
446
 
447
 
447
/* TT = 0x24, TL > 0, clean_window handler */
448
/* TT = 0x24, TL > 0, clean_window handler */
448
.org trap_table + (TT_CLEAN_WINDOW+512)*ENTRY_SIZE
449
.org trap_table + (TT_CLEAN_WINDOW+512)*ENTRY_SIZE
449
.global clean_window_handler_high
450
.global clean_window_handler_high
450
clean_window_handler_high:
451
clean_window_handler_high:
451
	CLEAN_WINDOW_HANDLER
452
	CLEAN_WINDOW_HANDLER
452
 
453
 
453
/* TT = 0x32, TL > 0, data_access_error */
454
/* TT = 0x32, TL > 0, data_access_error */
454
.org trap_table + (TT_DATA_ACCESS_ERROR+512)*ENTRY_SIZE
455
.org trap_table + (TT_DATA_ACCESS_ERROR+512)*ENTRY_SIZE
455
.global data_access_error_high
456
.global data_access_error_high
456
data_access_error_high:
457
data_access_error_high:
457
	PREEMPTIBLE_HANDLER do_data_access_error
458
	PREEMPTIBLE_HANDLER do_data_access_error
458
 
459
 
459
/* TT = 0x34, TL > 0, mem_address_not_aligned */
460
/* TT = 0x34, TL > 0, mem_address_not_aligned */
460
.org trap_table + (TT_MEM_ADDRESS_NOT_ALIGNED+512)*ENTRY_SIZE
461
.org trap_table + (TT_MEM_ADDRESS_NOT_ALIGNED+512)*ENTRY_SIZE
461
.global mem_address_not_aligned_high
462
.global mem_address_not_aligned_high
462
mem_address_not_aligned_high:
463
mem_address_not_aligned_high:
463
	PREEMPTIBLE_HANDLER do_mem_address_not_aligned
464
	MEM_ADDRESS_NOT_ALIGNED_HANDLER
464
 
465
 
465
/* TT = 0x64, TL > 0, fast_instruction_access_MMU_miss */
466
/* TT = 0x64, TL > 0, fast_instruction_access_MMU_miss */
466
.org trap_table + (TT_FAST_INSTRUCTION_ACCESS_MMU_MISS+512)*ENTRY_SIZE
467
.org trap_table + (TT_FAST_INSTRUCTION_ACCESS_MMU_MISS+512)*ENTRY_SIZE
467
.global fast_instruction_access_mmu_miss_handler_high
468
.global fast_instruction_access_mmu_miss_handler_high
468
fast_instruction_access_mmu_miss_handler_high:
469
fast_instruction_access_mmu_miss_handler_high:
469
	FAST_INSTRUCTION_ACCESS_MMU_MISS_HANDLER
470
	FAST_INSTRUCTION_ACCESS_MMU_MISS_HANDLER
470
 
471
 
471
/* TT = 0x68, TL > 0, fast_data_access_MMU_miss */
472
/* TT = 0x68, TL > 0, fast_data_access_MMU_miss */
472
.org trap_table + (TT_FAST_DATA_ACCESS_MMU_MISS+512)*ENTRY_SIZE
473
.org trap_table + (TT_FAST_DATA_ACCESS_MMU_MISS+512)*ENTRY_SIZE
473
.global fast_data_access_mmu_miss_handler_high
474
.global fast_data_access_mmu_miss_handler_high
474
fast_data_access_mmu_miss_handler_high:
475
fast_data_access_mmu_miss_handler_high:
475
	FAST_DATA_ACCESS_MMU_MISS_HANDLER
476
	FAST_DATA_ACCESS_MMU_MISS_HANDLER
476
 
477
 
477
/* TT = 0x6c, TL > 0, fast_data_access_protection */
478
/* TT = 0x6c, TL > 0, fast_data_access_protection */
478
.org trap_table + (TT_FAST_DATA_ACCESS_PROTECTION+512)*ENTRY_SIZE
479
.org trap_table + (TT_FAST_DATA_ACCESS_PROTECTION+512)*ENTRY_SIZE
479
.global fast_data_access_protection_handler_high
480
.global fast_data_access_protection_handler_high
480
fast_data_access_protection_handler_high:
481
fast_data_access_protection_handler_high:
481
	FAST_DATA_ACCESS_PROTECTION_HANDLER
482
	FAST_DATA_ACCESS_PROTECTION_HANDLER
482
 
483
 
483
/* TT = 0x80, TL > 0, spill_0_normal handler */
484
/* TT = 0x80, TL > 0, spill_0_normal handler */
484
.org trap_table + (TT_SPILL_0_NORMAL+512)*ENTRY_SIZE
485
.org trap_table + (TT_SPILL_0_NORMAL+512)*ENTRY_SIZE
485
.global spill_0_normal_high
486
.global spill_0_normal_high
486
spill_0_normal_high:
487
spill_0_normal_high:
487
	SPILL_NORMAL_HANDLER_KERNEL
488
	SPILL_NORMAL_HANDLER_KERNEL
488
 
489
 
489
/* TT = 0x88, TL > 0, spill_2_normal handler */
490
/* TT = 0x88, TL > 0, spill_2_normal handler */
490
.org trap_table + (TT_SPILL_2_NORMAL+512)*ENTRY_SIZE
491
.org trap_table + (TT_SPILL_2_NORMAL+512)*ENTRY_SIZE
491
.global spill_2_normal_high
492
.global spill_2_normal_high
492
spill_2_normal_high:
493
spill_2_normal_high:
493
	SPILL_TO_USPACE_WINDOW_BUFFER
494
	SPILL_TO_USPACE_WINDOW_BUFFER
494
 
495
 
495
/* TT = 0xa0, TL > 0, spill_0_other handler */
496
/* TT = 0xa0, TL > 0, spill_0_other handler */
496
.org trap_table + (TT_SPILL_0_OTHER+512)*ENTRY_SIZE
497
.org trap_table + (TT_SPILL_0_OTHER+512)*ENTRY_SIZE
497
.global spill_0_other_high
498
.global spill_0_other_high
498
spill_0_other_high:
499
spill_0_other_high:
499
	SPILL_TO_USPACE_WINDOW_BUFFER
500
	SPILL_TO_USPACE_WINDOW_BUFFER
500
 
501
 
501
/* TT = 0xc0, TL > 0, fill_0_normal handler */
502
/* TT = 0xc0, TL > 0, fill_0_normal handler */
502
.org trap_table + (TT_FILL_0_NORMAL+512)*ENTRY_SIZE
503
.org trap_table + (TT_FILL_0_NORMAL+512)*ENTRY_SIZE
503
.global fill_0_normal_high
504
.global fill_0_normal_high
504
fill_0_normal_high:
505
fill_0_normal_high:
505
	FILL_NORMAL_HANDLER_KERNEL
506
	FILL_NORMAL_HANDLER_KERNEL
506
 
507
 
507
#define NOT(x)	((x) == 0)
508
#define NOT(x)	((x) == 0)
508
 
509
 
509
/* Preemptible trap handler for TL=1.
510
/* Preemptible trap handler for TL=1.
510
 *
511
 *
511
 * This trap handler makes arrangements to make calling of scheduler() from
512
 * This trap handler makes arrangements to make calling of scheduler() from
512
 * within a trap context possible. It is called from several other trap
513
 * within a trap context possible. It is called from several other trap
513
 * handlers.
514
 * handlers.
514
 *
515
 *
515
 * This function can be entered either with interrupt globals or alternate globals.
516
 * This function can be entered either with interrupt globals or alternate globals.
516
 * Memory management trap handlers are obliged to switch to one of those global sets
517
 * Memory management trap handlers are obliged to switch to one of those global sets
517
 * prior to calling this function. Register window management functions are not
518
 * prior to calling this function. Register window management functions are not
518
 * allowed to modify the alternate global registers.
519
 * allowed to modify the alternate global registers.
519
 *
520
 *
520
 * Input registers:
521
 * Input registers:
521
 *	%g1		Address of function to call.
522
 *	%g1		Address of function to call.
522
 * 	%g2	 	First argument for the function.
523
 * 	%g2	 	First argument for the function.
523
 *	%g6		Pre-set as kernel stack base if trap from userspace.
524
 *	%g6		Pre-set as kernel stack base if trap from userspace.
524
 *	%g7		Pre-set as address of the userspace window buffer.
525
 *	%g7		Pre-set as address of the userspace window buffer.
525
 */
526
 */
526
.macro PREEMPTIBLE_HANDLER_TEMPLATE is_syscall
527
.macro PREEMPTIBLE_HANDLER_TEMPLATE is_syscall
-
 
528
	/*
-
 
529
	 * ASSERT(%tl == 1)
-
 
530
	 */
-
 
531
	rdpr %tl, %g3
-
 
532
	cmp %g3, 1
-
 
533
	be 1f
-
 
534
	nop
-
 
535
0:	ba 0b					! this for debugging, if we ever get here
-
 
536
	nop					! it will be easy to find
-
 
537
 
-
 
538
1:
527
.if NOT(\is_syscall)
539
.if NOT(\is_syscall)
528
	rdpr %tstate, %g3
540
	rdpr %tstate, %g3
529
	andcc %g3, TSTATE_PRIV_BIT, %g0		! if this trap came from the privileged mode...
541
	andcc %g3, TSTATE_PRIV_BIT, %g0		! if this trap came from the privileged mode...
530
	bnz 0f					! ...skip setting of kernel stack and primary context
542
	bnz 0f					! ...skip setting of kernel stack and primary context
531
	nop
543
	nop
532
.endif
544
.endif
533
	/*
545
	/*
534
	 * Normal window spills will go to the userspace window buffer.
546
	 * Normal window spills will go to the userspace window buffer.
535
	 */
547
	 */
536
	wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(2), %wstate
548
	wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(2), %wstate
537
 
549
 
-
 
550
	wrpr %g0, NWINDOW - 1, %cleanwin	! prevent unnecessary clean_window exceptions
-
 
551
 
538
	/*
552
	/*
539
	 * Switch to kernel stack. The old stack is
553
	 * Switch to kernel stack. The old stack is
540
	 * automatically saved in the old window's %sp
554
	 * automatically saved in the old window's %sp
541
	 * and the new window's %fp.
555
	 * and the new window's %fp.
542
	 */
556
	 */
543
	save %g6, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
557
	save %g6, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
544
 
558
 
545
.if \is_syscall
559
.if \is_syscall
546
	/*
560
	/*
547
	 * Copy arguments for the syscall to the new window.
561
	 * Copy arguments for the syscall to the new window.
548
	 */
562
	 */
549
	mov %i0, %o2
563
	mov %i0, %o2
550
	mov %i1, %o3
564
	mov %i1, %o3
551
	mov %i2, %o4
565
	mov %i2, %o4
552
	mov %i3, %o5
566
	mov %i3, %o5
553
.endif
567
.endif
554
 
568
 
555
	/*
569
	/*
556
	 * Mark the CANRESTORE windows as OTHER windows.
570
	 * Mark the CANRESTORE windows as OTHER windows.
557
	 * Set CLEANWIN to NWINDOW-1 so that clean_window traps do not occur.
-
 
558
	 */
571
	 */
559
	rdpr %canrestore, %l0
572
	rdpr %canrestore, %l0
560
	wrpr %l0, %otherwin
573
	wrpr %l0, %otherwin
561
	wrpr %g0, %canrestore
574
	wrpr %g0, %canrestore
562
	wrpr %g0, NWINDOW - 1, %cleanwin
-
 
563
 
575
 
564
	/*
576
	/*
565
	 * Switch to primary context 0.
577
	 * Switch to primary context 0.
566
	 */
578
	 */
567
	mov VA_PRIMARY_CONTEXT_REG, %l0
579
	mov VA_PRIMARY_CONTEXT_REG, %l0
568
	stxa %g0, [%l0] ASI_DMMU
580
	stxa %g0, [%l0] ASI_DMMU
569
	rd %pc, %l0
581
	rd %pc, %l0
570
	flush %l0
582
	flush %l0
571
 
583
 
572
.if NOT(\is_syscall)
584
.if NOT(\is_syscall)
573
	ba 1f
585
	ba 1f
574
	nop
586
	nop
575
 
587
 
576
0:
588
0:
577
	save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
589
	save %sp, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
578
 
590
 
579
	/*
591
	/*
580
	 * At this moment, we are using the kernel stack 
592
	 * At this moment, we are using the kernel stack 
581
	 * and have successfully allocated a register window.
593
	 * and have successfully allocated a register window.
582
	 */
594
	 */
583
1:
595
1:
584
.endif
596
.endif
585
	/*
597
	/*
586
	 * Other window spills will go to the userspace window buffer
598
	 * Other window spills will go to the userspace window buffer
587
	 * and normal spills will go to the kernel stack.
599
	 * and normal spills will go to the kernel stack.
588
	 */
600
	 */
589
	wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(0), %wstate
601
	wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(0), %wstate
590
	
602
	
591
	/*
603
	/*
592
	 * Copy arguments.
604
	 * Copy arguments.
593
	 */
605
	 */
594
	mov %g1, %l0
606
	mov %g1, %l0
595
	mov %g2, %o0
607
	mov %g2, %o0
596
 
608
 
597
	/*
609
	/*
598
	 * Save TSTATE, TPC and TNPC aside.
610
	 * Save TSTATE, TPC and TNPC aside.
599
	 */
611
	 */
600
	rdpr %tstate, %g1
612
	rdpr %tstate, %g1
601
	rdpr %tpc, %g2
613
	rdpr %tpc, %g2
602
	rdpr %tnpc, %g3
614
	rdpr %tnpc, %g3
603
 
615
 
604
	/*
616
	/*
605
	 * The following memory accesses will not fault
617
	 * The following memory accesses will not fault
606
	 * because special provisions are made to have
618
	 * because special provisions are made to have
607
	 * the kernel stack of THREAD locked in DTLB.
619
	 * the kernel stack of THREAD locked in DTLB.
608
	 */
620
	 */
609
	stx %g1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TSTATE]
621
	stx %g1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TSTATE]
610
	stx %g2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TPC]
622
	stx %g2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TPC]
611
	stx %g3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC]
623
	stx %g3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC]
612
	
624
	
613
	wrpr %g0, 0, %tl
625
	wrpr %g0, 0, %tl
614
	wrpr %g0, PSTATE_PRIV_BIT, %pstate
626
	wrpr %g0, PSTATE_PRIV_BIT, %pstate
615
	SAVE_GLOBALS
627
	SAVE_GLOBALS
616
	
628
	
617
	/*
629
	/*
618
	 * Call the higher-level handler and pass istate as second parameter.
630
	 * Call the higher-level handler and pass istate as second parameter.
619
	 */
631
	 */
620
	call %l0
632
	call %l0
621
	add %sp, PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC, %o1
633
	add %sp, PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC, %o1
622
 
634
 
623
.if \is_syscall
635
.if \is_syscall
624
	/*
636
	/*
625
	 * Copy the value returned by the syscall.
637
	 * Copy the value returned by the syscall.
626
	 */
638
	 */
627
	mov %o0, %i0
639
	mov %o0, %i0
628
.endif
640
.endif
629
 
641
 
630
	RESTORE_GLOBALS
642
	RESTORE_GLOBALS
631
	wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
643
	wrpr %g0, PSTATE_AG_BIT | PSTATE_PRIV_BIT, %pstate
632
	wrpr %g0, 1, %tl
644
	wrpr %g0, 1, %tl
633
	
645
	
634
	/*
646
	/*
635
	 * Read TSTATE, TPC and TNPC from saved copy.
647
	 * Read TSTATE, TPC and TNPC from saved copy.
636
	 */
648
	 */
637
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TSTATE], %g1
649
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TSTATE], %g1
638
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TPC], %g2
650
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TPC], %g2
639
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC], %g3
651
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_TNPC], %g3
640
 
652
 
641
	/*
653
	/*
642
	 * Restore TSTATE, TPC and TNPC from saved copies.
654
	 * Restore TSTATE, TPC and TNPC from saved copies.
643
	 */
655
	 */
644
	wrpr %g1, 0, %tstate
656
	wrpr %g1, 0, %tstate
645
	wrpr %g2, 0, %tpc
657
	wrpr %g2, 0, %tpc
646
	wrpr %g3, 0, %tnpc
658
	wrpr %g3, 0, %tnpc
647
 
659
 
648
	/*
660
	/*
649
	 * If OTHERWIN is zero, then all the userspace windows have been
661
	 * If OTHERWIN is zero, then all the userspace windows have been
650
	 * spilled to kernel memory (i.e. register window buffer). Moreover,
662
	 * spilled to kernel memory (i.e. register window buffer). Moreover,
651
	 * if the scheduler was called in the meantime, all valid windows
663
	 * if the scheduler was called in the meantime, all valid windows
652
	 * belonging to other threads were spilled by context_restore().
664
	 * belonging to other threads were spilled by context_restore().
653
	 * If OTHERWIN is non-zero, then some userspace windows are still
665
	 * If OTHERWIN is non-zero, then some userspace windows are still
654
	 * valid. Others might have been spilled. However, the CWP pointer
666
	 * valid. Others might have been spilled. However, the CWP pointer
655
	 * needs no fixing because the scheduler had not been called.
667
	 * needs no fixing because the scheduler had not been called.
656
	 */
668
	 */
657
	rdpr %otherwin, %l0
669
	rdpr %otherwin, %l0
658
	brnz %l0, 0f
670
	brnz %l0, 0f
659
	nop
671
	nop
660
 
672
 
661
	/*
673
	/*
662
	 * OTHERWIN == 0
674
	 * OTHERWIN == 0
663
	 */
675
	 */
664
 
676
 
665
	/*
677
	/*
666
	 * If TSTATE.CWP + 1 == CWP, then we still do not have to fix CWP.
678
	 * If TSTATE.CWP + 1 == CWP, then we still do not have to fix CWP.
667
	 */
679
	 */
668
	and %g1, TSTATE_CWP_MASK, %l0
680
	and %g1, TSTATE_CWP_MASK, %l0
669
	inc %l0
681
	inc %l0
670
	and %l0, NWINDOW - 1, %l0	! %l0 mod NWINDOW
682
	and %l0, NWINDOW - 1, %l0	! %l0 mod NWINDOW
671
	rdpr %cwp, %l1
683
	rdpr %cwp, %l1
672
	cmp %l0, %l1
684
	cmp %l0, %l1
673
	bz 0f				! CWP is ok
685
	bz 0f				! CWP is ok
674
	nop
686
	nop
675
 
687
 
676
	/*
688
	/*
677
	 * Fix CWP.
689
	 * Fix CWP.
678
	 * In order to recapitulate, the input registers in the current
690
	 * In order to recapitulate, the input registers in the current
679
	 * window are the output registers of the window to which we want
691
	 * window are the output registers of the window to which we want
680
	 * to restore. Because the fill trap fills only input and local
692
	 * to restore. Because the fill trap fills only input and local
681
	 * registers of a window, we need to preserve those output
693
	 * registers of a window, we need to preserve those output
682
	 * registers manually.
694
	 * registers manually.
683
	 */
695
	 */
684
	mov %sp, %g2
696
	mov %sp, %g2
685
	stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0]
697
	stx %i0, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0]
686
	stx %i1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1]
698
	stx %i1, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1]
687
	stx %i2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2]
699
	stx %i2, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2]
688
	stx %i3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3]
700
	stx %i3, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3]
689
	stx %i4, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I4]
701
	stx %i4, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I4]
690
	stx %i5, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I5]
702
	stx %i5, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I5]
691
	stx %i6, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6]
703
	stx %i6, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6]
692
	stx %i7, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7]
704
	stx %i7, [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7]
693
	wrpr %l0, 0, %cwp
705
	wrpr %l0, 0, %cwp
694
	mov %g2, %sp
706
	mov %g2, %sp
695
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0], %i0
707
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I0], %i0
696
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1], %i1
708
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I1], %i1
697
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2], %i2
709
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I2], %i2
698
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3], %i3
710
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I3], %i3
699
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I4], %i4
711
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I4], %i4
700
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I5], %i5
712
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I5], %i5
701
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6], %i6
713
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I6], %i6
702
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7], %i7
714
	ldx [%sp + PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE + STACK_BIAS + SAVED_I7], %i7
703
 
715
 
704
	/*
716
	/*
705
	 * OTHERWIN != 0 or fall-through from the OTHERWIN == 0 case.
717
	 * OTHERWIN != 0 or fall-through from the OTHERWIN == 0 case.
706
	 * The CWP has already been restored to the value it had prior to the SAVE
718
	 * The CWP has already been restored to the value it had prior to the SAVE
707
	 * at the beginning of this function.
719
	 * at the beginning of this function.
708
	 */
720
	 */
709
0:
721
0:
710
.if NOT(\is_syscall)
722
.if NOT(\is_syscall)
711
	rdpr %tstate, %g1
723
	rdpr %tstate, %g1
712
	andcc %g1, TSTATE_PRIV_BIT, %g0		! if we are not returning to userspace...,
724
	andcc %g1, TSTATE_PRIV_BIT, %g0		! if we are not returning to userspace...,
713
	bnz 1f					! ...skip restoring userspace windows
725
	bnz 1f					! ...skip restoring userspace windows
714
	nop
726
	nop
715
.endif
727
.endif
716
 
728
 
717
	/*
729
	/*
718
	 * Spills and fills will be processed by the {spill,fill}_1_normal
730
	 * Spills and fills will be processed by the {spill,fill}_1_normal
719
	 * handlers.
731
	 * handlers.
720
	 */
732
	 */
721
	wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
733
	wrpr %g0, WSTATE_OTHER(0) | WSTATE_NORMAL(1), %wstate
722
 
734
 
723
	/*
735
	/*
724
	 * Set primary context according to secondary context.
736
	 * Set primary context according to secondary context.
725
	 */
737
	 */
726
	wr %g0, ASI_DMMU, %asi
738
	wr %g0, ASI_DMMU, %asi
727
	ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1
739
	ldxa [VA_SECONDARY_CONTEXT_REG] %asi, %g1
728
	stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
740
	stxa %g1, [VA_PRIMARY_CONTEXT_REG] %asi
-
 
741
	rd %pc, %g1
729
	flush %o7
742
	flush %g1
730
	
743
	
731
	rdpr %cwp, %g1
744
	rdpr %cwp, %g1
732
	rdpr %otherwin, %g2
745
	rdpr %otherwin, %g2
733
 
746
 
734
	/*
747
	/*
735
	 * Skip all OTHERWIN windows and descend to the first window
748
	 * Skip all OTHERWIN windows and descend to the first window
736
	 * in the userspace window buffer.
749
	 * in the userspace window buffer.
737
	 */
750
	 */
738
	sub %g1, %g2, %g3
751
	sub %g1, %g2, %g3
739
	dec %g3
752
	dec %g3
740
	and %g3, NWINDOW - 1, %g3
753
	and %g3, NWINDOW - 1, %g3
741
	wrpr %g3, 0, %cwp
754
	wrpr %g3, 0, %cwp
742
 
755
 
743
	/*
756
	/*
744
	 * CWP is now in the window last saved in the userspace window buffer.
757
	 * CWP is now in the window last saved in the userspace window buffer.
745
	 * Fill all windows stored in the buffer.
758
	 * Fill all windows stored in the buffer.
746
	 */
759
	 */
747
	clr %g4
760
	clr %g4
748
	set PAGE_SIZE - 1, %g5
761
	set PAGE_SIZE - 1, %g5
749
0:	andcc %g7, %g5, %g0			! PAGE_SIZE alignment check
762
0:	andcc %g7, %g5, %g0			! PAGE_SIZE alignment check
750
	bz 0f					! %g7 is page-aligned, no more windows to refill
763
	bz 0f					! %g7 is page-aligned, no more windows to refill
751
	nop
764
	nop
752
 
765
 
753
	add %g7, -STACK_WINDOW_SAVE_AREA_SIZE, %g7
766
	add %g7, -STACK_WINDOW_SAVE_AREA_SIZE, %g7
754
	ldx [%g7 + L0_OFFSET], %l0
767
	ldx [%g7 + L0_OFFSET], %l0
755
	ldx [%g7 + L1_OFFSET], %l1
768
	ldx [%g7 + L1_OFFSET], %l1
756
	ldx [%g7 + L2_OFFSET], %l2
769
	ldx [%g7 + L2_OFFSET], %l2
757
	ldx [%g7 + L3_OFFSET], %l3
770
	ldx [%g7 + L3_OFFSET], %l3
758
	ldx [%g7 + L4_OFFSET], %l4
771
	ldx [%g7 + L4_OFFSET], %l4
759
	ldx [%g7 + L5_OFFSET], %l5
772
	ldx [%g7 + L5_OFFSET], %l5
760
	ldx [%g7 + L6_OFFSET], %l6
773
	ldx [%g7 + L6_OFFSET], %l6
761
	ldx [%g7 + L7_OFFSET], %l7
774
	ldx [%g7 + L7_OFFSET], %l7
762
	ldx [%g7 + I0_OFFSET], %i0
775
	ldx [%g7 + I0_OFFSET], %i0
763
	ldx [%g7 + I1_OFFSET], %i1
776
	ldx [%g7 + I1_OFFSET], %i1
764
	ldx [%g7 + I2_OFFSET], %i2
777
	ldx [%g7 + I2_OFFSET], %i2
765
	ldx [%g7 + I3_OFFSET], %i3
778
	ldx [%g7 + I3_OFFSET], %i3
766
	ldx [%g7 + I4_OFFSET], %i4
779
	ldx [%g7 + I4_OFFSET], %i4
767
	ldx [%g7 + I5_OFFSET], %i5
780
	ldx [%g7 + I5_OFFSET], %i5
768
	ldx [%g7 + I6_OFFSET], %i6
781
	ldx [%g7 + I6_OFFSET], %i6
769
	ldx [%g7 + I7_OFFSET], %i7
782
	ldx [%g7 + I7_OFFSET], %i7
770
 
783
 
771
	dec %g3
784
	dec %g3
772
	and %g3, NWINDOW - 1, %g3
785
	and %g3, NWINDOW - 1, %g3
773
	wrpr %g3, 0, %cwp			! switch to the preceeding window
786
	wrpr %g3, 0, %cwp			! switch to the preceeding window
774
 
787
 
775
	ba 0b
788
	ba 0b
776
	inc %g4
789
	inc %g4
777
 
790
 
778
0:
791
0:
779
	/*
792
	/*
780
	 * Switch back to the proper current window and adjust
793
	 * Switch back to the proper current window and adjust
781
	 * OTHERWIN, CANRESTORE, CANSAVE and CLEANWIN.
794
	 * OTHERWIN, CANRESTORE, CANSAVE and CLEANWIN.
782
	 */
795
	 */
783
	wrpr %g1, 0, %cwp
796
	wrpr %g1, 0, %cwp
784
	add %g4, %g2, %g2
797
	add %g4, %g2, %g2
785
	cmp %g2, NWINDOW - 2
798
	cmp %g2, NWINDOW - 2
786
	bg 2f					! fix the CANRESTORE=NWINDOW-1 anomaly
799
	bg 2f					! fix the CANRESTORE=NWINDOW-1 anomaly
787
	mov NWINDOW - 2, %g1			! use dealy slot for both cases
800
	mov NWINDOW - 2, %g1			! use dealy slot for both cases
788
	sub %g1, %g2, %g1
801
	sub %g1, %g2, %g1
789
	
802
	
790
	wrpr %g0, 0, %otherwin
803
	wrpr %g0, 0, %otherwin
791
	wrpr %g1, 0, %cansave			! NWINDOW - 2 - CANRESTORE
804
	wrpr %g1, 0, %cansave			! NWINDOW - 2 - CANRESTORE
792
	wrpr %g2, 0, %canrestore		! OTHERWIN + windows in the buffer
805
	wrpr %g2, 0, %canrestore		! OTHERWIN + windows in the buffer
793
	wrpr %g2, 0, %cleanwin			! avoid information leak
806
	wrpr %g2, 0, %cleanwin			! avoid information leak
794
 
807
 
795
1:
808
1:
796
	restore
809
	restore
797
 
810
 
798
.if \is_syscall
811
.if \is_syscall
799
	done
812
	done
800
.else
813
.else
801
	retry
814
	retry
802
.endif
815
.endif
803
 
816
 
804
	/*
817
	/*
805
	 * We got here in order to avoid inconsistency of the window state registers.
818
	 * We got here in order to avoid inconsistency of the window state registers.
806
	 * If the:
819
	 * If the:
807
	 *
820
	 *
808
	 * 	save %g6, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
821
	 * 	save %g6, -PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE, %sp
809
	 *
822
	 *
810
	 * instruction trapped and spilled a register window into the userspace
823
	 * instruction trapped and spilled a register window into the userspace
811
	 * window buffer, we have just restored NWINDOW - 1 register windows.
824
	 * window buffer, we have just restored NWINDOW - 1 register windows.
812
	 * However, CANRESTORE can be only NWINDOW - 2 at most.
825
	 * However, CANRESTORE can be only NWINDOW - 2 at most.
813
	 *
826
	 *
814
	 * The solution is to manually switch to (CWP - 1) mod NWINDOW
827
	 * The solution is to manually switch to (CWP - 1) mod NWINDOW
815
	 * and set the window state registers so that:
828
	 * and set the window state registers so that:
816
	 *
829
	 *
817
	 * 	CANRESTORE 	= NWINDOW - 2
830
	 * 	CANRESTORE 	= NWINDOW - 2
818
	 *	CLEANWIN	= NWINDOW - 2
831
	 *	CLEANWIN	= NWINDOW - 2
819
	 *	CANSAVE 	= 0
832
	 *	CANSAVE 	= 0
820
	 *	OTHERWIN	= 0
833
	 *	OTHERWIN	= 0
821
	 *
834
	 *
822
	 * The RESTORE isntruction is therfore to be skipped.
835
	 * The RESTORE isntruction is therfore to be skipped.
823
	 */
836
	 */
824
2:
837
2:
825
	wrpr %g0, 0, %otherwin
838
	wrpr %g0, 0, %otherwin
826
	wrpr %g0, 0, %cansave
839
	wrpr %g0, 0, %cansave
827
	wrpr %g1, 0, %canrestore
840
	wrpr %g1, 0, %canrestore
828
	wrpr %g1, 0, %cleanwin
841
	wrpr %g1, 0, %cleanwin
829
 
842
 
830
	rdpr %cwp, %g1
843
	rdpr %cwp, %g1
831
	dec %g1
844
	dec %g1
832
	and %g1, NWINDOW - 1, %g1
845
	and %g1, NWINDOW - 1, %g1
833
	wrpr %g1, 0, %cwp			! CWP--
846
	wrpr %g1, 0, %cwp			! CWP--
834
	
847
	
835
.if \is_syscall
848
.if \is_syscall
836
	done
849
	done
837
.else
850
.else
838
	retry
851
	retry
839
.endif
852
.endif
840
 
853
 
841
.endm
854
.endm
842
 
855
 
843
.global preemptible_handler
856
.global preemptible_handler
844
preemptible_handler:
857
preemptible_handler:
845
	PREEMPTIBLE_HANDLER_TEMPLATE 0
858
	PREEMPTIBLE_HANDLER_TEMPLATE 0
846
 
859
 
847
.global trap_instruction_handler
860
.global trap_instruction_handler
848
trap_instruction_handler:
861
trap_instruction_handler:
849
	PREEMPTIBLE_HANDLER_TEMPLATE 1
862
	PREEMPTIBLE_HANDLER_TEMPLATE 1
850
 
863