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