Rev 863 | 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 | /** |
||
883 | jermar | 30 | * This file contains kernel trap table. |
529 | jermar | 31 | */ |
666 | jermar | 32 | |
33 | .register %g2, #scratch |
||
34 | .register %g3, #scratch |
||
35 | .register %g6, #scratch |
||
36 | .register %g7, #scratch |
||
37 | |||
529 | jermar | 38 | .text |
39 | |||
630 | jermar | 40 | #include <arch/trap/trap_table.h> |
41 | #include <arch/trap/regwin.h> |
||
663 | jermar | 42 | #include <arch/trap/interrupt.h> |
667 | jermar | 43 | #include <arch/trap/exception.h> |
863 | jermar | 44 | #include <arch/trap/mmu.h> |
667 | jermar | 45 | #include <arch/stack.h> |
529 | jermar | 46 | |
47 | #define TABLE_SIZE TRAP_TABLE_SIZE |
||
48 | #define ENTRY_SIZE TRAP_TABLE_ENTRY_SIZE |
||
49 | |||
50 | /* |
||
634 | jermar | 51 | * Kernel trap table. |
529 | jermar | 52 | */ |
53 | .align TABLE_SIZE |
||
54 | .global trap_table |
||
55 | trap_table: |
||
56 | |||
667 | jermar | 57 | /* TT = 0x08, TL = 0, instruction_access_exception */ |
58 | .org trap_table + TT_INSTRUCTION_ACCESS_EXCEPTION*ENTRY_SIZE |
||
59 | .global instruction_access_exception |
||
60 | instruction_access_exception: |
||
61 | SIMPLE_HANDLER do_instruction_access_exc |
||
62 | |||
883 | jermar | 63 | /* TT = 0x10, TL = 0, illegal_instruction */ |
64 | .org trap_table + TT_ILLEGAL_INSTRUCTION*ENTRY_SIZE |
||
65 | .global illegal_instruction |
||
66 | illegal_instruction: |
||
67 | SIMPLE_HANDLER do_illegal_instruction |
||
68 | |||
663 | jermar | 69 | /* TT = 0x24, TL = 0, clean_window handler */ |
634 | jermar | 70 | .org trap_table + TT_CLEAN_WINDOW*ENTRY_SIZE |
630 | jermar | 71 | .global clean_window_handler |
72 | clean_window_handler: |
||
73 | CLEAN_WINDOW_HANDLER |
||
529 | jermar | 74 | |
667 | jermar | 75 | /* TT = 0x34, TL = 0, mem_address_not_aligned */ |
76 | .org trap_table + TT_MEM_ADDRESS_NOT_ALIGNED*ENTRY_SIZE |
||
77 | .global mem_address_not_aligned |
||
78 | mem_address_not_aligned: |
||
79 | SIMPLE_HANDLER do_mem_address_not_aligned |
||
80 | |||
664 | jermar | 81 | /* TT = 0x41, TL = 0, interrupt_level_1 handler */ |
82 | .org trap_table + TT_INTERRUPT_LEVEL_1*ENTRY_SIZE |
||
83 | .global interrupt_level_1_handler |
||
84 | interrupt_level_1_handler: |
||
85 | INTERRUPT_LEVEL_N_HANDLER 1 |
||
86 | |||
87 | /* TT = 0x42, TL = 0, interrupt_level_2 handler */ |
||
88 | .org trap_table + TT_INTERRUPT_LEVEL_2*ENTRY_SIZE |
||
89 | .global interrupt_level_2_handler |
||
90 | interrupt_level_2_handler: |
||
91 | INTERRUPT_LEVEL_N_HANDLER 2 |
||
92 | |||
93 | /* TT = 0x43, TL = 0, interrupt_level_3 handler */ |
||
94 | .org trap_table + TT_INTERRUPT_LEVEL_3*ENTRY_SIZE |
||
95 | .global interrupt_level_3_handler |
||
96 | interrupt_level_3_handler: |
||
97 | INTERRUPT_LEVEL_N_HANDLER 3 |
||
98 | |||
99 | /* TT = 0x44, TL = 0, interrupt_level_4 handler */ |
||
100 | .org trap_table + TT_INTERRUPT_LEVEL_4*ENTRY_SIZE |
||
101 | .global interrupt_level_4_handler |
||
102 | interrupt_level_4_handler: |
||
103 | INTERRUPT_LEVEL_N_HANDLER 4 |
||
104 | |||
105 | /* TT = 0x45, TL = 0, interrupt_level_5 handler */ |
||
106 | .org trap_table + TT_INTERRUPT_LEVEL_5*ENTRY_SIZE |
||
107 | .global interrupt_level_5_handler |
||
108 | interrupt_level_5_handler: |
||
109 | INTERRUPT_LEVEL_N_HANDLER 5 |
||
110 | |||
111 | /* TT = 0x46, TL = 0, interrupt_level_6 handler */ |
||
112 | .org trap_table + TT_INTERRUPT_LEVEL_6*ENTRY_SIZE |
||
113 | .global interrupt_level_6_handler |
||
114 | interrupt_level_6_handler: |
||
115 | INTERRUPT_LEVEL_N_HANDLER 6 |
||
116 | |||
117 | /* TT = 0x47, TL = 0, interrupt_level_7 handler */ |
||
118 | .org trap_table + TT_INTERRUPT_LEVEL_7*ENTRY_SIZE |
||
119 | .global interrupt_level_7_handler |
||
120 | interrupt_level_7_handler: |
||
121 | INTERRUPT_LEVEL_N_HANDLER 7 |
||
122 | |||
123 | /* TT = 0x48, TL = 0, interrupt_level_8 handler */ |
||
124 | .org trap_table + TT_INTERRUPT_LEVEL_8*ENTRY_SIZE |
||
125 | .global interrupt_level_8_handler |
||
126 | interrupt_level_8_handler: |
||
127 | INTERRUPT_LEVEL_N_HANDLER 8 |
||
128 | |||
129 | /* TT = 0x49, TL = 0, interrupt_level_9 handler */ |
||
130 | .org trap_table + TT_INTERRUPT_LEVEL_9*ENTRY_SIZE |
||
131 | .global interrupt_level_9_handler |
||
132 | interrupt_level_9_handler: |
||
133 | INTERRUPT_LEVEL_N_HANDLER 9 |
||
134 | |||
135 | /* TT = 0x4a, TL = 0, interrupt_level_10 handler */ |
||
136 | .org trap_table + TT_INTERRUPT_LEVEL_10*ENTRY_SIZE |
||
137 | .global interrupt_level_10_handler |
||
138 | interrupt_level_10_handler: |
||
139 | INTERRUPT_LEVEL_N_HANDLER 10 |
||
140 | |||
141 | /* TT = 0x4b, TL = 0, interrupt_level_11 handler */ |
||
142 | .org trap_table + TT_INTERRUPT_LEVEL_11*ENTRY_SIZE |
||
143 | .global interrupt_level_11_handler |
||
144 | interrupt_level_11_handler: |
||
145 | INTERRUPT_LEVEL_N_HANDLER 11 |
||
146 | |||
147 | /* TT = 0x4c, TL = 0, interrupt_level_12 handler */ |
||
148 | .org trap_table + TT_INTERRUPT_LEVEL_12*ENTRY_SIZE |
||
149 | .global interrupt_level_12_handler |
||
150 | interrupt_level_12_handler: |
||
151 | INTERRUPT_LEVEL_N_HANDLER 12 |
||
152 | |||
153 | /* TT = 0x4d, TL = 0, interrupt_level_13 handler */ |
||
154 | .org trap_table + TT_INTERRUPT_LEVEL_13*ENTRY_SIZE |
||
155 | .global interrupt_level_13_handler |
||
156 | interrupt_level_13_handler: |
||
157 | INTERRUPT_LEVEL_N_HANDLER 13 |
||
158 | |||
159 | /* TT = 0x4e, TL = 0, interrupt_level_14 handler */ |
||
160 | .org trap_table + TT_INTERRUPT_LEVEL_14*ENTRY_SIZE |
||
161 | .global interrupt_level_14_handler |
||
162 | interrupt_level_14_handler: |
||
163 | INTERRUPT_LEVEL_N_HANDLER 14 |
||
164 | |||
165 | /* TT = 0x4f, TL = 0, interrupt_level_15 handler */ |
||
166 | .org trap_table + TT_INTERRUPT_LEVEL_15*ENTRY_SIZE |
||
167 | .global interrupt_level_15_handler |
||
168 | interrupt_level_15_handler: |
||
169 | INTERRUPT_LEVEL_N_HANDLER 15 |
||
170 | |||
663 | jermar | 171 | /* TT = 0x60, TL = 0, interrupt_vector_trap handler */ |
172 | .org trap_table + TT_INTERRUPT_VECTOR_TRAP*ENTRY_SIZE |
||
173 | .global interrupt_vector_trap_handler |
||
174 | interrupt_vector_trap_handler: |
||
175 | INTERRUPT_VECTOR_TRAP_HANDLER |
||
176 | |||
863 | jermar | 177 | /* TT = 0x64, TL = 0, fast_instruction_access_MMU_miss */ |
178 | .org trap_table + TT_FAST_INSTRUCTION_ACCESS_MMU_MISS*ENTRY_SIZE |
||
179 | .global fast_instruction_access_mmu_miss_handler |
||
180 | fast_instruction_access_mmu_miss_handler: |
||
181 | FAST_INSTRUCTION_ACCESS_MMU_MISS_HANDLER |
||
182 | |||
183 | /* TT = 0x68, TL = 0, fast_data_access_MMU_miss */ |
||
184 | .org trap_table + TT_FAST_DATA_ACCESS_MMU_MISS*ENTRY_SIZE |
||
185 | .global fast_data_access_mmu_miss_handler |
||
186 | fast_data_access_mmu_miss_handler: |
||
187 | FAST_DATA_ACCESS_MMU_MISS_HANDLER |
||
188 | |||
189 | /* TT = 0x6c, TL = 0, fast_data_access_protection */ |
||
190 | .org trap_table + TT_FAST_DATA_ACCESS_PROTECTION*ENTRY_SIZE |
||
191 | .global fast_data_access_protection_handler |
||
192 | fast_data_access_protection_handler: |
||
193 | FAST_DATA_ACCESS_PROTECTION_HANDLER |
||
194 | |||
663 | jermar | 195 | /* TT = 0x80, TL = 0, spill_0_normal handler */ |
634 | jermar | 196 | .org trap_table + TT_SPILL_0_NORMAL*ENTRY_SIZE |
630 | jermar | 197 | .global spill_0_normal |
198 | spill_0_normal: |
||
199 | SPILL_NORMAL_HANDLER |
||
529 | jermar | 200 | |
663 | jermar | 201 | /* TT = 0xc0, TL = 0, fill_0_normal handler */ |
634 | jermar | 202 | .org trap_table + TT_FILL_0_NORMAL*ENTRY_SIZE |
663 | jermar | 203 | .global fill_0_normal |
630 | jermar | 204 | fill_0_normal: |
205 | FILL_NORMAL_HANDLER |
||
206 | |||
529 | jermar | 207 | /* |
663 | jermar | 208 | * Handlers for TL>0. |
529 | jermar | 209 | */ |
210 | |||
667 | jermar | 211 | /* TT = 0x08, TL > 0, instruction_access_exception */ |
212 | .org trap_table + (TT_INSTRUCTION_ACCESS_EXCEPTION+512)*ENTRY_SIZE |
||
213 | .global instruction_access_exception_high |
||
214 | instruction_access_exception_high: |
||
215 | SIMPLE_HANDLER do_instruction_access_exc |
||
216 | |||
883 | jermar | 217 | /* TT = 0x10, TL > 0, illegal_instruction */ |
218 | .org trap_table + (TT_ILLEGAL_INSTRUCTION+512)*ENTRY_SIZE |
||
219 | .global illegal_instruction_high |
||
220 | illegal_instruction_high: |
||
221 | SIMPLE_HANDLER do_illegal_instruction |
||
222 | |||
663 | jermar | 223 | /* TT = 0x24, TL > 0, clean_window handler */ |
224 | .org trap_table + (TT_CLEAN_WINDOW+512)*ENTRY_SIZE |
||
225 | .global clean_window_handler_high |
||
226 | clean_window_handler_high: |
||
227 | CLEAN_WINDOW_HANDLER |
||
529 | jermar | 228 | |
667 | jermar | 229 | /* TT = 0x34, TL > 0, mem_address_not_aligned */ |
230 | .org trap_table + (TT_MEM_ADDRESS_NOT_ALIGNED+512)*ENTRY_SIZE |
||
231 | .global mem_address_not_aligned_high |
||
232 | mem_address_not_aligned_high: |
||
233 | SIMPLE_HANDLER do_mem_address_not_aligned |
||
529 | jermar | 234 | |
863 | jermar | 235 | /* TT = 0x64, TL > 0, fast_instruction_access_MMU_miss */ |
236 | .org trap_table + (TT_FAST_INSTRUCTION_ACCESS_MMU_MISS+512)*ENTRY_SIZE |
||
237 | .global fast_instruction_access_mmu_miss_handler_high |
||
238 | fast_instruction_access_mmu_miss_handler_high: |
||
239 | FAST_INSTRUCTION_ACCESS_MMU_MISS_HANDLER |
||
240 | |||
241 | /* TT = 0x68, TL > 0, fast_data_access_MMU_miss */ |
||
242 | .org trap_table + (TT_FAST_DATA_ACCESS_MMU_MISS+512)*ENTRY_SIZE |
||
243 | .global fast_data_access_mmu_miss_handler_high |
||
244 | fast_data_access_mmu_miss_handler_high: |
||
245 | FAST_DATA_ACCESS_MMU_MISS_HANDLER |
||
246 | |||
247 | /* TT = 0x6c, TL > 0, fast_data_access_protection */ |
||
248 | .org trap_table + (TT_FAST_DATA_ACCESS_PROTECTION+512)*ENTRY_SIZE |
||
249 | .global fast_data_access_protection_handler_high |
||
250 | fast_data_access_protection_handler_high: |
||
251 | FAST_DATA_ACCESS_PROTECTION_HANDLER |
||
252 | |||
663 | jermar | 253 | /* TT = 0x80, TL > 0, spill_0_normal handler */ |
254 | .org trap_table + (TT_SPILL_0_NORMAL+512)*ENTRY_SIZE |
||
255 | .global spill_0_normal_high |
||
256 | spill_0_normal_high: |
||
257 | SPILL_NORMAL_HANDLER |
||
529 | jermar | 258 | |
663 | jermar | 259 | /* TT = 0xc0, TL > 0, fill_0_normal handler */ |
260 | .org trap_table + (TT_FILL_0_NORMAL+512)*ENTRY_SIZE |
||
261 | .global fill_0_normal_high |
||
262 | fill_0_normal_high: |
||
263 | FILL_NORMAL_HANDLER |
||
634 | jermar | 264 | |
663 | jermar | 265 | |
667 | jermar | 266 | /* Preemptible trap handler. |
666 | jermar | 267 | * |
667 | jermar | 268 | * This trap handler makes arrangements to |
269 | * make calling scheduler() possible. |
||
270 | * |
||
271 | * The caller is responsible for doing save |
||
272 | * and allocating PREEMPTIBLE_HANDLER_STACK_FRAME_SIZE |
||
273 | * bytes on stack. |
||
274 | * |
||
666 | jermar | 275 | * Input registers: |
276 | * %l0 Address of function to call. |
||
277 | * Output registers: |
||
278 | * %l1 - %l7 Copy of %g1 - %g7 |
||
279 | */ |
||
667 | jermar | 280 | .global preemptible_handler |
281 | preemptible_handler: |
||
282 | /* |
||
283 | * Save TSTATE, TPC, TNPC and PSTATE aside. |
||
284 | */ |
||
285 | rdpr %tstate, %g1 |
||
286 | rdpr %tpc, %g2 |
||
287 | rdpr %tnpc, %g3 |
||
288 | rdpr %pstate, %g4 |
||
289 | |||
290 | stx %g1, [%fp + STACK_BIAS + SAVED_TSTATE] |
||
291 | stx %g2, [%fp + STACK_BIAS + SAVED_TPC] |
||
292 | stx %g3, [%fp + STACK_BIAS + SAVED_TNPC] |
||
293 | stx %g4, [%fp + STACK_BIAS + SAVED_PSTATE] |
||
294 | |||
295 | /* |
||
296 | * Write 0 to TL. |
||
297 | */ |
||
298 | wrpr %g0, 0, %tl |
||
299 | |||
300 | /* |
||
301 | * Alter PSTATE. |
||
302 | * - switch to normal globals. |
||
303 | */ |
||
304 | and %g4, ~1, %g4 ! mask alternate globals |
||
305 | wrpr %g4, 0, %pstate |
||
306 | |||
307 | /* |
||
308 | * Save the normal globals. |
||
309 | */ |
||
666 | jermar | 310 | SAVE_GLOBALS |
667 | jermar | 311 | |
312 | /* |
||
313 | * Call the higher-level handler. |
||
314 | */ |
||
666 | jermar | 315 | call %l0 |
316 | nop |
||
667 | jermar | 317 | |
318 | /* |
||
319 | * Restore the normal global register set. |
||
320 | */ |
||
666 | jermar | 321 | RESTORE_GLOBALS |
667 | jermar | 322 | |
323 | /* |
||
324 | * Restore PSTATE from saved copy. |
||
325 | * Alternate globals become active. |
||
326 | */ |
||
327 | ldx [%fp + STACK_BIAS + SAVED_PSTATE], %l4 |
||
328 | wrpr %l4, 0, %pstate |
||
329 | |||
330 | /* |
||
331 | * Write 1 to TL. |
||
332 | */ |
||
333 | wrpr %g0, 1, %tl |
||
334 | |||
335 | /* |
||
336 | * Read TSTATE, TPC and TNPC from saved copy. |
||
337 | */ |
||
338 | ldx [%fp + STACK_BIAS + SAVED_TSTATE], %g1 |
||
339 | ldx [%fp + STACK_BIAS + SAVED_TPC], %g2 |
||
340 | ldx [%fp + STACK_BIAS + SAVED_TNPC], %g3 |
||
341 | |||
342 | /* |
||
343 | * Do restore to match the save instruction from the top-level handler. |
||
344 | */ |
||
345 | restore |
||
346 | |||
347 | /* |
||
348 | * On execution of retry instruction, CWP will be restored from TSTATE register. |
||
349 | * However, because of scheduling, it is possible that CWP in saved TSTATE |
||
350 | * is different from current CWP. The following chunk of code fixes CWP |
||
351 | * in the saved copy of TSTATE. |
||
352 | */ |
||
353 | rdpr %cwp, %g4 ! read current CWP |
||
354 | and %g1, ~0x1f, %g1 ! clear CWP field in saved TSTATE |
||
355 | or %g1, %g4, %g1 ! write current CWP to TSTATE |
||
356 | |||
357 | /* |
||
358 | * Restore TSTATE, TPC and TNPC from saved copies. |
||
359 | */ |
||
360 | wrpr %g1, 0, %tstate |
||
361 | wrpr %g2, 0, %tpc |
||
362 | wrpr %g3, 0, %tnpc |
||
363 | |||
364 | /* |
||
365 | * Return from interrupt. |
||
366 | */ |
||
666 | jermar | 367 | retry |