Subversion Repositories HelenOS

Rev

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

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