Subversion Repositories HelenOS-historic

Rev

Rev 666 | Rev 883 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 666 Rev 667
Line 46... Line 46...
46
.text
46
.text
47
 
47
 
48
#include <arch/trap/trap_table.h>
48
#include <arch/trap/trap_table.h>
49
#include <arch/trap/regwin.h>
49
#include <arch/trap/regwin.h>
50
#include <arch/trap/interrupt.h>
50
#include <arch/trap/interrupt.h>
-
 
51
#include <arch/trap/exception.h>
-
 
52
#include <arch/stack.h>
51
 
53
 
52
#define TABLE_SIZE	TRAP_TABLE_SIZE
54
#define TABLE_SIZE	TRAP_TABLE_SIZE
53
#define ENTRY_SIZE	TRAP_TABLE_ENTRY_SIZE
55
#define ENTRY_SIZE	TRAP_TABLE_ENTRY_SIZE
54
 
56
 
55
/*
57
/*
Line 57... Line 59...
57
 */
59
 */
58
.align TABLE_SIZE
60
.align TABLE_SIZE
59
.global trap_table
61
.global trap_table
60
trap_table:
62
trap_table:
61
 
63
 
-
 
64
/* TT = 0x08, TL = 0, instruction_access_exception */
-
 
65
.org trap_table + TT_INSTRUCTION_ACCESS_EXCEPTION*ENTRY_SIZE
-
 
66
.global instruction_access_exception
-
 
67
instruction_access_exception:
-
 
68
	SIMPLE_HANDLER do_instruction_access_exc
-
 
69
 
62
/* TT = 0x24, TL = 0, clean_window handler */
70
/* TT = 0x24, TL = 0, clean_window handler */
63
.org trap_table + TT_CLEAN_WINDOW*ENTRY_SIZE
71
.org trap_table + TT_CLEAN_WINDOW*ENTRY_SIZE
64
.global clean_window_handler
72
.global clean_window_handler
65
clean_window_handler:
73
clean_window_handler:
66
	CLEAN_WINDOW_HANDLER
74
	CLEAN_WINDOW_HANDLER
67
 
75
 
-
 
76
/* TT = 0x34, TL = 0, mem_address_not_aligned */
-
 
77
.org trap_table + TT_MEM_ADDRESS_NOT_ALIGNED*ENTRY_SIZE
-
 
78
.global mem_address_not_aligned
-
 
79
mem_address_not_aligned:
-
 
80
	SIMPLE_HANDLER do_mem_address_not_aligned
-
 
81
 
68
/* TT = 0x41, TL = 0, interrupt_level_1 handler */
82
/* TT = 0x41, TL = 0, interrupt_level_1 handler */
69
.org trap_table + TT_INTERRUPT_LEVEL_1*ENTRY_SIZE
83
.org trap_table + TT_INTERRUPT_LEVEL_1*ENTRY_SIZE
70
.global interrupt_level_1_handler
84
.global interrupt_level_1_handler
71
interrupt_level_1_handler:
85
interrupt_level_1_handler:
72
	INTERRUPT_LEVEL_N_HANDLER 1
86
	INTERRUPT_LEVEL_N_HANDLER 1
Line 175... Line 189...
175
 
189
 
176
/*
190
/*
177
 * Handlers for TL>0.
191
 * Handlers for TL>0.
178
 */
192
 */
179
 
193
 
-
 
194
/* TT = 0x08, TL > 0, instruction_access_exception */
-
 
195
.org trap_table + (TT_INSTRUCTION_ACCESS_EXCEPTION+512)*ENTRY_SIZE
-
 
196
.global instruction_access_exception_high
-
 
197
instruction_access_exception_high:
-
 
198
	SIMPLE_HANDLER do_instruction_access_exc
-
 
199
 
180
/* TT = 0x24, TL > 0, clean_window handler */
200
/* TT = 0x24, TL > 0, clean_window handler */
181
.org trap_table + (TT_CLEAN_WINDOW+512)*ENTRY_SIZE
201
.org trap_table + (TT_CLEAN_WINDOW+512)*ENTRY_SIZE
182
.global clean_window_handler_high
202
.global clean_window_handler_high
183
clean_window_handler_high:
203
clean_window_handler_high:
184
	CLEAN_WINDOW_HANDLER
204
	CLEAN_WINDOW_HANDLER
185
 
205
 
-
 
206
/* TT = 0x34, TL > 0, mem_address_not_aligned */
-
 
207
.org trap_table + (TT_MEM_ADDRESS_NOT_ALIGNED+512)*ENTRY_SIZE
-
 
208
.global mem_address_not_aligned_high
-
 
209
mem_address_not_aligned_high:
-
 
210
	SIMPLE_HANDLER do_mem_address_not_aligned
186
 
211
 
187
/* TT = 0x80, TL > 0, spill_0_normal handler */
212
/* TT = 0x80, TL > 0, spill_0_normal handler */
188
 
-
 
189
.org trap_table + (TT_SPILL_0_NORMAL+512)*ENTRY_SIZE
213
.org trap_table + (TT_SPILL_0_NORMAL+512)*ENTRY_SIZE
190
.global spill_0_normal_high
214
.global spill_0_normal_high
191
spill_0_normal_high:
215
spill_0_normal_high:
192
	SPILL_NORMAL_HANDLER
216
	SPILL_NORMAL_HANDLER
193
 
217
 
194
 
-
 
195
/* TT = 0xc0, TL > 0, fill_0_normal handler */
218
/* TT = 0xc0, TL > 0, fill_0_normal handler */
196
.org trap_table + (TT_FILL_0_NORMAL+512)*ENTRY_SIZE
219
.org trap_table + (TT_FILL_0_NORMAL+512)*ENTRY_SIZE
197
.global fill_0_normal_high
220
.global fill_0_normal_high
198
fill_0_normal_high:
221
fill_0_normal_high:
199
	FILL_NORMAL_HANDLER
222
	FILL_NORMAL_HANDLER
Line 207... Line 230...
207
.global trap_table_save
230
.global trap_table_save
208
trap_table_save:
231
trap_table_save:
209
	.space TABLE_SIZE, 0
232
	.space TABLE_SIZE, 0
210
 
233
 
211
 
234
 
-
 
235
/* Preemptible trap handler.
-
 
236
 *
-
 
237
 * This trap handler makes arrangements to
-
 
238
 * make calling scheduler() possible.
-
 
239
 *
212
/* Trap handler that explicitly saves global registers.
240
 * The caller is responsible for doing save
-
 
241
 * and allocating PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE
-
 
242
 * bytes on stack.
213
 *
243
 *
214
 * Input registers:
244
 * Input registers:
215
 * 	%l0	 	Address of function to call.
245
 * 	%l0	 	Address of function to call.
216
 * Output registers:
246
 * Output registers:
217
 *	 %l1 - %l7 	Copy of %g1 - %g7
247
 *	 %l1 - %l7 	Copy of %g1 - %g7
218
 */
248
 */
219
.global saving_handler
249
.global preemptible_handler
220
saving_handler:
250
preemptible_handler:
-
 
251
	/*
-
 
252
	 * Save TSTATE, TPC, TNPC and PSTATE aside.
-
 
253
	 */
-
 
254
	rdpr %tstate, %g1
-
 
255
	rdpr %tpc, %g2
-
 
256
	rdpr %tnpc, %g3
-
 
257
	rdpr %pstate, %g4
-
 
258
 
-
 
259
	stx %g1, [%fp + STACK_BIAS + SAVED_TSTATE]
-
 
260
	stx %g2, [%fp + STACK_BIAS + SAVED_TPC]
-
 
261
	stx %g3, [%fp + STACK_BIAS + SAVED_TNPC]
-
 
262
	stx %g4, [%fp + STACK_BIAS + SAVED_PSTATE]
-
 
263
	
-
 
264
	/*
-
 
265
	 * Write 0 to TL.
-
 
266
	 */
-
 
267
	wrpr %g0, 0, %tl
-
 
268
	
-
 
269
	/*
-
 
270
	 * Alter PSTATE.
-
 
271
	 * - switch to normal globals.
-
 
272
	 */
-
 
273
	and %g4, ~1, %g4		! mask alternate globals
-
 
274
	wrpr %g4, 0, %pstate
-
 
275
	 
-
 
276
	/*
-
 
277
	 * Save the normal globals.
-
 
278
	 */
221
	SAVE_GLOBALS
279
	SAVE_GLOBALS
-
 
280
	
-
 
281
	/*
-
 
282
	 * Call the higher-level handler.
-
 
283
	 */
222
	call %l0
284
	call %l0
223
	nop
285
	nop
-
 
286
	
-
 
287
	/*
-
 
288
	 * Restore the normal global register set.
-
 
289
	 */
224
	RESTORE_GLOBALS
290
	RESTORE_GLOBALS
-
 
291
	
-
 
292
	/*
-
 
293
	 * Restore PSTATE from saved copy.
-
 
294
	 * Alternate globals become active.
-
 
295
	 */
-
 
296
	ldx [%fp + STACK_BIAS + SAVED_PSTATE], %l4
-
 
297
	wrpr %l4, 0, %pstate
-
 
298
	
-
 
299
	/*
-
 
300
	 * Write 1 to TL.
-
 
301
	 */
-
 
302
	wrpr %g0, 1, %tl
-
 
303
	
-
 
304
	/*
-
 
305
	 * Read TSTATE, TPC and TNPC from saved copy.
-
 
306
	 */
-
 
307
	ldx [%fp + STACK_BIAS + SAVED_TSTATE], %g1
-
 
308
	ldx [%fp + STACK_BIAS + SAVED_TPC], %g2
-
 
309
	ldx [%fp + STACK_BIAS + SAVED_TNPC], %g3
-
 
310
 
-
 
311
	/*
225
	restore		/* matches the save instruction from the top-level handler */
312
	 * Do restore to match the save instruction from the top-level handler.
-
 
313
	 */
-
 
314
	restore
-
 
315
 
-
 
316
	/*
-
 
317
	 * On execution of retry instruction, CWP will be restored from TSTATE register.
-
 
318
	 * However, because of scheduling, it is possible that CWP in saved TSTATE
-
 
319
	 * is different from current CWP. The following chunk of code fixes CWP
-
 
320
	 * in the saved copy of TSTATE.
-
 
321
	 */
-
 
322
	rdpr %cwp, %g4		! read current CWP
-
 
323
	and %g1, ~0x1f, %g1	! clear CWP field in saved TSTATE
-
 
324
	or %g1, %g4, %g1	! write current CWP to TSTATE
-
 
325
	
-
 
326
	/*
-
 
327
	 * Restore TSTATE, TPC and TNPC from saved copies.
-
 
328
	 */
-
 
329
	wrpr %g1, 0, %tstate
-
 
330
	wrpr %g2, 0, %tpc
-
 
331
	wrpr %g3, 0, %tnpc
-
 
332
	 
-
 
333
	/*
-
 
334
	 * Return from interrupt.
-
 
335
	 */
226
	retry
336
	retry