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