Subversion Repositories HelenOS

Rev

Rev 664 | Rev 667 | 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
/**
634 jermar 30
 * This file contains two trap tables.
31
 * First, trap_table, is the one wich contains handlers implemented by
32
 * kernel. During initialization, these handlers are copied out to
33
 * the second trap table, trap_table_save, and the first table is
34
 * overwritten with copy of OFW's own trap table. The copy is then patched
35
 * from the trap_table_save.
36
 *
37
 * This arrangement is beneficial because kernel handlers stay on their
38
 * link-time addresses which is good for debugging.
529 jermar 39
 */
666 jermar 40
 
41
.register %g2, #scratch
42
.register %g3, #scratch
43
.register %g6, #scratch
44
.register %g7, #scratch 
45
 
529 jermar 46
.text
47
 
630 jermar 48
#include <arch/trap/trap_table.h>
49
#include <arch/trap/regwin.h>
663 jermar 50
#include <arch/trap/interrupt.h>
529 jermar 51
 
52
#define TABLE_SIZE	TRAP_TABLE_SIZE
53
#define ENTRY_SIZE	TRAP_TABLE_ENTRY_SIZE
54
 
55
/*
634 jermar 56
 * Kernel trap table.
529 jermar 57
 */
58
.align TABLE_SIZE
59
.global trap_table
60
trap_table:
61
 
663 jermar 62
/* TT = 0x24, TL = 0, clean_window handler */
634 jermar 63
.org trap_table + TT_CLEAN_WINDOW*ENTRY_SIZE
630 jermar 64
.global clean_window_handler
65
clean_window_handler:
66
	CLEAN_WINDOW_HANDLER
529 jermar 67
 
664 jermar 68
/* TT = 0x41, TL = 0, interrupt_level_1 handler */
69
.org trap_table + TT_INTERRUPT_LEVEL_1*ENTRY_SIZE
70
.global interrupt_level_1_handler
71
interrupt_level_1_handler:
72
	INTERRUPT_LEVEL_N_HANDLER 1
73
 
74
/* TT = 0x42, TL = 0, interrupt_level_2 handler */
75
.org trap_table + TT_INTERRUPT_LEVEL_2*ENTRY_SIZE
76
.global interrupt_level_2_handler
77
interrupt_level_2_handler:
78
	INTERRUPT_LEVEL_N_HANDLER 2
79
 
80
/* TT = 0x43, TL = 0, interrupt_level_3 handler */
81
.org trap_table + TT_INTERRUPT_LEVEL_3*ENTRY_SIZE
82
.global interrupt_level_3_handler
83
interrupt_level_3_handler:
84
	INTERRUPT_LEVEL_N_HANDLER 3
85
 
86
/* TT = 0x44, TL = 0, interrupt_level_4 handler */
87
.org trap_table + TT_INTERRUPT_LEVEL_4*ENTRY_SIZE
88
.global interrupt_level_4_handler
89
interrupt_level_4_handler:
90
	INTERRUPT_LEVEL_N_HANDLER 4
91
 
92
/* TT = 0x45, TL = 0, interrupt_level_5 handler */
93
.org trap_table + TT_INTERRUPT_LEVEL_5*ENTRY_SIZE
94
.global interrupt_level_5_handler
95
interrupt_level_5_handler:
96
	INTERRUPT_LEVEL_N_HANDLER 5
97
 
98
/* TT = 0x46, TL = 0, interrupt_level_6 handler */
99
.org trap_table + TT_INTERRUPT_LEVEL_6*ENTRY_SIZE
100
.global interrupt_level_6_handler
101
interrupt_level_6_handler:
102
	INTERRUPT_LEVEL_N_HANDLER 6
103
 
104
/* TT = 0x47, TL = 0, interrupt_level_7 handler */
105
.org trap_table + TT_INTERRUPT_LEVEL_7*ENTRY_SIZE
106
.global interrupt_level_7_handler
107
interrupt_level_7_handler:
108
	INTERRUPT_LEVEL_N_HANDLER 7
109
 
110
/* TT = 0x48, TL = 0, interrupt_level_8 handler */
111
.org trap_table + TT_INTERRUPT_LEVEL_8*ENTRY_SIZE
112
.global interrupt_level_8_handler
113
interrupt_level_8_handler:
114
	INTERRUPT_LEVEL_N_HANDLER 8
115
 
116
/* TT = 0x49, TL = 0, interrupt_level_9 handler */
117
.org trap_table + TT_INTERRUPT_LEVEL_9*ENTRY_SIZE
118
.global interrupt_level_9_handler
119
interrupt_level_9_handler:
120
	INTERRUPT_LEVEL_N_HANDLER 9
121
 
122
/* TT = 0x4a, TL = 0, interrupt_level_10 handler */
123
.org trap_table + TT_INTERRUPT_LEVEL_10*ENTRY_SIZE
124
.global interrupt_level_10_handler
125
interrupt_level_10_handler:
126
	INTERRUPT_LEVEL_N_HANDLER 10
127
 
128
/* TT = 0x4b, TL = 0, interrupt_level_11 handler */
129
.org trap_table + TT_INTERRUPT_LEVEL_11*ENTRY_SIZE
130
.global interrupt_level_11_handler
131
interrupt_level_11_handler:
132
	INTERRUPT_LEVEL_N_HANDLER 11
133
 
134
/* TT = 0x4c, TL = 0, interrupt_level_12 handler */
135
.org trap_table + TT_INTERRUPT_LEVEL_12*ENTRY_SIZE
136
.global interrupt_level_12_handler
137
interrupt_level_12_handler:
138
	INTERRUPT_LEVEL_N_HANDLER 12
139
 
140
/* TT = 0x4d, TL = 0, interrupt_level_13 handler */
141
.org trap_table + TT_INTERRUPT_LEVEL_13*ENTRY_SIZE
142
.global interrupt_level_13_handler
143
interrupt_level_13_handler:
144
	INTERRUPT_LEVEL_N_HANDLER 13
145
 
146
/* TT = 0x4e, TL = 0, interrupt_level_14 handler */
147
.org trap_table + TT_INTERRUPT_LEVEL_14*ENTRY_SIZE
148
.global interrupt_level_14_handler
149
interrupt_level_14_handler:
150
	INTERRUPT_LEVEL_N_HANDLER 14
151
 
152
/* TT = 0x4f, TL = 0, interrupt_level_15 handler */
153
.org trap_table + TT_INTERRUPT_LEVEL_15*ENTRY_SIZE
154
.global interrupt_level_15_handler
155
interrupt_level_15_handler:
156
	INTERRUPT_LEVEL_N_HANDLER 15
157
 
663 jermar 158
/* TT = 0x60, TL = 0, interrupt_vector_trap handler */
159
.org trap_table + TT_INTERRUPT_VECTOR_TRAP*ENTRY_SIZE
160
.global interrupt_vector_trap_handler
161
interrupt_vector_trap_handler:
162
	INTERRUPT_VECTOR_TRAP_HANDLER
163
 
164
/* TT = 0x80, TL = 0, spill_0_normal handler */
634 jermar 165
.org trap_table + TT_SPILL_0_NORMAL*ENTRY_SIZE
630 jermar 166
.global spill_0_normal
167
spill_0_normal:
168
	SPILL_NORMAL_HANDLER
529 jermar 169
 
663 jermar 170
/* TT = 0xc0, TL = 0, fill_0_normal handler */
634 jermar 171
.org trap_table + TT_FILL_0_NORMAL*ENTRY_SIZE
663 jermar 172
.global fill_0_normal
630 jermar 173
fill_0_normal:
174
	FILL_NORMAL_HANDLER
175
 
529 jermar 176
/*
663 jermar 177
 * Handlers for TL>0.
529 jermar 178
 */
179
 
663 jermar 180
/* TT = 0x24, TL > 0, clean_window handler */
181
.org trap_table + (TT_CLEAN_WINDOW+512)*ENTRY_SIZE
182
.global clean_window_handler_high
183
clean_window_handler_high:
184
	CLEAN_WINDOW_HANDLER
529 jermar 185
 
186
 
663 jermar 187
/* TT = 0x80, TL > 0, spill_0_normal handler */
529 jermar 188
 
663 jermar 189
.org trap_table + (TT_SPILL_0_NORMAL+512)*ENTRY_SIZE
190
.global spill_0_normal_high
191
spill_0_normal_high:
192
	SPILL_NORMAL_HANDLER
529 jermar 193
 
634 jermar 194
 
663 jermar 195
/* TT = 0xc0, TL > 0, fill_0_normal handler */
196
.org trap_table + (TT_FILL_0_NORMAL+512)*ENTRY_SIZE
197
.global fill_0_normal_high
198
fill_0_normal_high:
199
	FILL_NORMAL_HANDLER
634 jermar 200
 
663 jermar 201
 
202
 
634 jermar 203
/*
204
 * Save trap table.
205
 */
663 jermar 206
.align TABLE_SIZE
634 jermar 207
.global trap_table_save
208
trap_table_save:
209
	.space TABLE_SIZE, 0
666 jermar 210
 
211
 
212
/* Trap handler that explicitly saves global registers.
213
 *
214
 * Input registers:
215
 * 	%l0	 	Address of function to call.
216
 * Output registers:
217
 *	 %l1 - %l7 	Copy of %g1 - %g7
218
 */
219
.global saving_handler
220
saving_handler:
221
	SAVE_GLOBALS
222
	call %l0
223
	nop
224
	RESTORE_GLOBALS
225
	restore		/* matches the save instruction from the top-level handler */
226
	retry