Subversion Repositories HelenOS

Rev

Rev 1865 | Rev 1876 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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