Rev 899 | Rev 912 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 899 | Rev 911 | ||
---|---|---|---|
1 | # |
1 | # |
2 | # Copyright (C) 2005 Jakub Vana |
2 | # Copyright (C) 2005 Jakub Vana |
3 | # Copyright (C) 2005 Jakub Jermar |
3 | # Copyright (C) 2005 Jakub Jermar |
4 | # All rights reserved. |
4 | # All rights reserved. |
5 | # |
5 | # |
6 | # Redistribution and use in source and binary forms, with or without |
6 | # Redistribution and use in source and binary forms, with or without |
7 | # modification, are permitted provided that the following conditions |
7 | # modification, are permitted provided that the following conditions |
8 | # are met: |
8 | # are met: |
9 | # |
9 | # |
10 | # - Redistributions of source code must retain the above copyright |
10 | # - Redistributions of source code must retain the above copyright |
11 | # notice, this list of conditions and the following disclaimer. |
11 | # notice, this list of conditions and the following disclaimer. |
12 | # - Redistributions in binary form must reproduce the above copyright |
12 | # - Redistributions in binary form must reproduce the above copyright |
13 | # notice, this list of conditions and the following disclaimer in the |
13 | # notice, this list of conditions and the following disclaimer in the |
14 | # documentation and/or other materials provided with the distribution. |
14 | # documentation and/or other materials provided with the distribution. |
15 | # - The name of the author may not be used to endorse or promote products |
15 | # - The name of the author may not be used to endorse or promote products |
16 | # derived from this software without specific prior written permission. |
16 | # derived from this software without specific prior written permission. |
17 | # |
17 | # |
18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
18 | # THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR |
19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
19 | # IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES |
20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
20 | # OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. |
21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
21 | # IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, |
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
22 | # INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT |
23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
23 | # NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
26 | # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF |
27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
27 | # THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | # |
28 | # |
29 | 29 | ||
30 | #include <arch/stack.h> |
30 | #include <arch/stack.h> |
31 | #include <arch/register.h> |
31 | #include <arch/register.h> |
32 | 32 | ||
33 | #define STACK_ITEMS 12 |
33 | #define STACK_ITEMS 12 |
34 | #define STACK_FRAME_SIZE ((STACK_ITEMS*STACK_ITEM_SIZE) + STACK_SCRATCH_AREA_SIZE) |
34 | #define STACK_FRAME_SIZE ((STACK_ITEMS*STACK_ITEM_SIZE) + STACK_SCRATCH_AREA_SIZE) |
35 | 35 | ||
36 | #if (STACK_FRAME_SIZE % STACK_ALIGNMENT != 0) |
36 | #if (STACK_FRAME_SIZE % STACK_ALIGNMENT != 0) |
37 | #error Memory stack must be 16-byte aligned. |
37 | #error Memory stack must be 16-byte aligned. |
38 | #endif |
38 | #endif |
39 | 39 | ||
- | 40 | /** Partitioning of bank 0 registers. */ |
|
- | 41 | #define R_OFFS r16 |
|
- | 42 | #define R_HANDLER r17 |
|
- | 43 | #define R_RET r18 |
|
- | 44 | #define R_KSTACK r23 /* keep in sync with before_thread_runs_arch() */ |
|
- | 45 | ||
40 | /** Heavyweight interrupt handler |
46 | /** Heavyweight interrupt handler |
41 | * |
47 | * |
42 | * This macro roughly follows steps from 1 to 19 described in |
48 | * This macro roughly follows steps from 1 to 19 described in |
43 | * Intel Itanium Architecture Software Developer's Manual, Chapter 3.4.2. |
49 | * Intel Itanium Architecture Software Developer's Manual, Chapter 3.4.2. |
44 | * |
50 | * |
45 | * HEAVYWEIGHT_HANDLER macro must cram into 16 bundles (48 instructions). |
51 | * HEAVYWEIGHT_HANDLER macro must cram into 16 bundles (48 instructions). |
46 | * This goal is achieved by using procedure calls after RSE becomes operational. |
52 | * This goal is achieved by using procedure calls after RSE becomes operational. |
47 | * |
53 | * |
48 | * Some steps are skipped (enabling and disabling interrupts). |
54 | * Some steps are skipped (enabling and disabling interrupts). |
49 | * Some steps are not fully supported yet (e.g. interruptions |
55 | * Some steps are not fully supported yet (e.g. interruptions |
50 | * from userspace and floating-point context). |
56 | * from userspace and floating-point context). |
51 | * |
57 | * |
52 | * @param offs Offset from the beginning of IVT. |
58 | * @param offs Offset from the beginning of IVT. |
53 | * @param handler Interrupt handler address. |
59 | * @param handler Interrupt handler address. |
54 | */ |
60 | */ |
55 | .macro HEAVYWEIGHT_HANDLER offs, handler=universal_handler |
61 | .macro HEAVYWEIGHT_HANDLER offs, handler=universal_handler |
56 | .org ivt + \offs |
62 | .org ivt + \offs |
57 | mov r24 = \offs |
63 | mov R_OFFS = \offs |
58 | movl r25 = \handler ;; |
64 | movl R_HANDLER = \handler ;; |
59 | mov ar.k0 = r24 |
- | |
60 | mov ar.k1 = r25 |
- | |
61 | br heavyweight_handler |
65 | br heavyweight_handler |
62 | .endm |
66 | .endm |
63 | 67 | ||
64 | .global heavyweight_handler |
68 | .global heavyweight_handler |
65 | heavyweight_handler: |
69 | heavyweight_handler: |
66 | /* 1. copy interrupt registers into bank 0 */ |
70 | /* 1. copy interrupt registers into bank 0 */ |
- | 71 | ||
- | 72 | /* |
|
- | 73 | * Note that r24-r31 from bank0 can be used only as long as PSR.ic = 0. |
|
- | 74 | */ |
|
67 | mov r24 = cr.iip |
75 | mov r24 = cr.iip |
68 | mov r25 = cr.ipsr |
76 | mov r25 = cr.ipsr |
69 | mov r26 = cr.iipa |
77 | mov r26 = cr.iipa |
70 | mov r27 = cr.isr |
78 | mov r27 = cr.isr |
71 | mov r28 = cr.ifa |
79 | mov r28 = cr.ifa |
72 | 80 | ||
73 | /* 2. preserve predicate register into bank 0 */ |
81 | /* 2. preserve predicate register into bank 0 */ |
74 | mov r29 = pr ;; |
82 | mov r29 = pr ;; |
75 | 83 | ||
76 | /* 3. switch to kernel memory stack */ |
84 | /* 3. switch to kernel memory stack */ |
77 | /* TODO: support interruptions from userspace */ |
85 | /* TODO: support interruptions from userspace */ |
78 | /* assume kernel stack */ |
86 | /* assume kernel stack */ |
79 | 87 | ||
80 | add r31 = -8, r12 ;; |
88 | add r31 = -8, r12 ;; |
81 | add r12 = -STACK_FRAME_SIZE, r12 |
89 | add r12 = -STACK_FRAME_SIZE, r12 |
82 | 90 | ||
83 | /* 4. save registers in bank 0 into memory stack */ |
91 | /* 4. save registers in bank 0 into memory stack */ |
84 | st8 [r31] = r29, -8 ;; /* save predicate registers */ |
92 | st8 [r31] = r29, -8 ;; /* save predicate registers */ |
85 | 93 | ||
86 | st8 [r31] = r24, -8 ;; /* save cr.iip */ |
94 | st8 [r31] = r24, -8 ;; /* save cr.iip */ |
87 | st8 [r31] = r25, -8 ;; /* save cr.ipsr */ |
95 | st8 [r31] = r25, -8 ;; /* save cr.ipsr */ |
88 | st8 [r31] = r26, -8 ;; /* save cr.iipa */ |
96 | st8 [r31] = r26, -8 ;; /* save cr.iipa */ |
89 | st8 [r31] = r27, -8 ;; /* save cr.isr */ |
97 | st8 [r31] = r27, -8 ;; /* save cr.isr */ |
90 | st8 [r31] = r28, -8 /* save cr.ifa */ |
98 | st8 [r31] = r28, -8 /* save cr.ifa */ |
91 | 99 | ||
92 | /* 5. RSE switch from interrupted context */ |
100 | /* 5. RSE switch from interrupted context */ |
93 | mov r24 = ar.rsc |
101 | mov r24 = ar.rsc |
94 | mov r25 = ar.pfs |
102 | mov r25 = ar.pfs |
95 | cover |
103 | cover |
96 | mov r26 = cr.ifs |
104 | mov r26 = cr.ifs |
97 | 105 | ||
98 | st8 [r31] = r24, -8;; /* save ar.rsc */ |
106 | st8 [r31] = r24, -8;; /* save ar.rsc */ |
99 | st8 [r31] = r25, -8;; /* save ar.pfs */ |
107 | st8 [r31] = r25, -8;; /* save ar.pfs */ |
100 | st8 [r31] = r26, -8 /* save ar.ifs */ |
108 | st8 [r31] = r26, -8 /* save ar.ifs */ |
101 | 109 | ||
102 | and r30 = ~3, r24 ;; |
110 | and r30 = ~3, r24 ;; |
103 | mov ar.rsc = r30 ;; /* place RSE in enforced lazy mode */ |
111 | mov ar.rsc = r30 ;; /* place RSE in enforced lazy mode */ |
104 | 112 | ||
105 | mov r27 = ar.rnat |
113 | mov r27 = ar.rnat |
106 | mov r28 = ar.bspstore ;; |
114 | mov r28 = ar.bspstore ;; |
107 | 115 | ||
108 | /* assume kernel backing store */ |
116 | /* assume kernel backing store */ |
109 | /* mov ar.bspstore = r28 ;; */ |
117 | /* mov ar.bspstore = r28 ;; */ |
110 | 118 | ||
111 | mov r29 = ar.bsp |
119 | mov r29 = ar.bsp |
112 | 120 | ||
113 | st8 [r31] = r27, -8 ;; /* save ar.rnat */ |
121 | st8 [r31] = r27, -8 ;; /* save ar.rnat */ |
114 | st8 [r31] = r28, -8 ;; /* save ar.bspstore */ |
122 | st8 [r31] = r28, -8 ;; /* save ar.bspstore */ |
115 | st8 [r31] = r29, -8 /* save ar.bsp */ |
123 | st8 [r31] = r29, -8 /* save ar.bsp */ |
116 | 124 | ||
117 | mov ar.rsc = r24 /* restore RSE's setting */ |
125 | mov ar.rsc = r24 /* restore RSE's setting */ |
118 | 126 | ||
119 | /* steps 6 - 15 are done by heavyweight_handler_inner() */ |
127 | /* steps 6 - 15 are done by heavyweight_handler_inner() */ |
120 | mov r24 = b0 /* save b0 belonging to interrupted context */ |
128 | mov R_RET = b0 /* save b0 belonging to interrupted context */ |
121 | mov r26 = ar.k0 |
- | |
122 | mov r25 = ar.k1 |
- | |
123 | br.call.sptk.many rp = heavyweight_handler_inner |
129 | br.call.sptk.many b0 = heavyweight_handler_inner |
124 | 0: mov b0 = r24 /* restore b0 belonging to the interrupted context */ |
130 | 0: mov b0 = R_RET /* restore b0 belonging to the interrupted context */ |
125 | 131 | ||
126 | /* 16. RSE switch to interrupted context */ |
132 | /* 16. RSE switch to interrupted context */ |
127 | cover /* allocate zerro size frame (step 1 (from Intel Docs)) */ |
133 | cover /* allocate zerro size frame (step 1 (from Intel Docs)) */ |
128 | 134 | ||
129 | add r31 = STACK_SCRATCH_AREA_SIZE, r12 ;; |
135 | add r31 = STACK_SCRATCH_AREA_SIZE, r12 ;; |
130 | 136 | ||
131 | mov r28 = ar.bspstore /* calculate loadrs (step 2) */ |
137 | mov r28 = ar.bspstore /* calculate loadrs (step 2) */ |
132 | ld8 r29 = [r31], +8 ;; /* load ar.bsp */ |
138 | ld8 r29 = [r31], +8 ;; /* load ar.bsp */ |
133 | sub r27 = r29 , r28 ;; |
139 | sub r27 = r29 , r28 ;; |
134 | shl r27 = r27, 16 |
140 | shl r27 = r27, 16 |
135 | 141 | ||
136 | mov r24 = ar.rsc ;; |
142 | mov r24 = ar.rsc ;; |
137 | and r30 = ~3, r24 ;; |
143 | and r30 = ~3, r24 ;; |
138 | or r24 = r30 , r27 ;; |
144 | or r24 = r30 , r27 ;; |
139 | mov ar.rsc = r24 ;; /* place RSE in enforced lazy mode */ |
145 | mov ar.rsc = r24 ;; /* place RSE in enforced lazy mode */ |
140 | 146 | ||
141 | loadrs /* (step 3) */ |
147 | loadrs /* (step 3) */ |
142 | 148 | ||
143 | ld8 r28 = [r31], +8 ;; /* load ar.bspstore */ |
149 | ld8 r28 = [r31], +8 ;; /* load ar.bspstore */ |
144 | ld8 r27 = [r31], +8 ;; /* load ar.rnat */ |
150 | ld8 r27 = [r31], +8 ;; /* load ar.rnat */ |
145 | ld8 r26 = [r31], +8 ;; /* load cr.ifs */ |
151 | ld8 r26 = [r31], +8 ;; /* load cr.ifs */ |
146 | ld8 r25 = [r31], +8 ;; /* load ar.pfs */ |
152 | ld8 r25 = [r31], +8 ;; /* load ar.pfs */ |
147 | ld8 r24 = [r31], +8 ;; /* load ar.rsc */ |
153 | ld8 r24 = [r31], +8 ;; /* load ar.rsc */ |
148 | 154 | ||
149 | /* mov ar.bspstore = r28 ;; */ /* (step 4) */ |
155 | /* mov ar.bspstore = r28 ;; */ /* (step 4) */ |
150 | /* mov ar.rnat = r27 */ /* (step 5) */ |
156 | /* mov ar.rnat = r27 */ /* (step 5) */ |
151 | 157 | ||
152 | mov ar.pfs = r25 /* (step 6) */ |
158 | mov ar.pfs = r25 /* (step 6) */ |
153 | mov cr.ifs = r26 |
159 | mov cr.ifs = r26 |
154 | 160 | ||
155 | mov ar.rsc = r24 /* (step 7) */ |
161 | mov ar.rsc = r24 /* (step 7) */ |
156 | 162 | ||
157 | /* 17. restore interruption state from memory stack */ |
163 | /* 17. restore interruption state from memory stack */ |
158 | ld8 r28 = [r31], +8 ;; /* load cr.ifa */ |
164 | ld8 r28 = [r31], +8 ;; /* load cr.ifa */ |
159 | ld8 r27 = [r31], +8 ;; /* load cr.isr */ |
165 | ld8 r27 = [r31], +8 ;; /* load cr.isr */ |
160 | ld8 r26 = [r31], +8 ;; /* load cr.iipa */ |
166 | ld8 r26 = [r31], +8 ;; /* load cr.iipa */ |
161 | ld8 r25 = [r31], +8 ;; /* load cr.ipsr */ |
167 | ld8 r25 = [r31], +8 ;; /* load cr.ipsr */ |
162 | ld8 r24 = [r31], +8 ;; /* load cr.iip */ |
168 | ld8 r24 = [r31], +8 ;; /* load cr.iip */ |
163 | 169 | ||
164 | mov cr.iip = r24 |
170 | mov cr.iip = r24 |
165 | mov cr.ipsr = r25 |
171 | mov cr.ipsr = r25 |
166 | mov cr.iipa = r26 |
172 | mov cr.iipa = r26 |
167 | mov cr.isr = r27 |
173 | mov cr.isr = r27 |
168 | mov cr.ifa = r28 |
174 | mov cr.ifa = r28 |
169 | 175 | ||
170 | /* 18. restore predicate registers from memory stack */ |
176 | /* 18. restore predicate registers from memory stack */ |
171 | ld8 r29 = [r31] , -8 ;; /* load predicate registers */ |
177 | ld8 r29 = [r31] , -8 ;; /* load predicate registers */ |
172 | mov pr = r29 |
178 | mov pr = r29 |
173 | 179 | ||
174 | /* 19. return from interruption */ |
180 | /* 19. return from interruption */ |
175 | add r12 = STACK_FRAME_SIZE, r12 |
181 | add r12 = STACK_FRAME_SIZE, r12 |
176 | rfi ;; |
182 | rfi ;; |
177 | 183 | ||
178 | .global heavyweight_handler_inner |
184 | .global heavyweight_handler_inner |
179 | heavyweight_handler_inner: |
185 | heavyweight_handler_inner: |
180 | /* |
186 | /* |
181 | * From this point, the rest of the interrupted context |
187 | * From this point, the rest of the interrupted context |
182 | * will be preserved in stacked registers and backing store. |
188 | * will be preserved in stacked registers and backing store. |
183 | */ |
189 | */ |
184 | alloc loc0 = ar.pfs, 0, 47, 2, 0 ;; |
190 | alloc loc0 = ar.pfs, 0, 47, 2, 0 ;; |
185 | 191 | ||
186 | /* bank 0 is going to be shadowed, copy essential data from there */ |
192 | /* bank 0 is going to be shadowed, copy essential data from there */ |
187 | mov loc1 = r24 /* b0 belonging to interrupted context */ |
193 | mov loc1 = R_RET /* b0 belonging to interrupted context */ |
188 | mov loc2 = r25 |
194 | mov loc2 = R_HANDLER |
189 | mov out0 = r26 |
195 | mov out0 = R_OFFS |
190 | 196 | ||
191 | add out1 = STACK_SCRATCH_AREA_SIZE, r12 |
197 | add out1 = STACK_SCRATCH_AREA_SIZE, r12 |
192 | 198 | ||
193 | /* 6. switch to bank 1 and reenable PSR.ic */ |
199 | /* 6. switch to bank 1 and reenable PSR.ic */ |
194 | ssm PSR_IC_MASK |
200 | ssm PSR_IC_MASK |
195 | bsw.1 ;; |
201 | bsw.1 ;; |
196 | srlz.d |
202 | srlz.d |
197 | 203 | ||
198 | /* 7. preserve branch and application registers */ |
204 | /* 7. preserve branch and application registers */ |
199 | mov loc3 = ar.unat |
205 | mov loc3 = ar.unat |
200 | mov loc4 = ar.lc |
206 | mov loc4 = ar.lc |
201 | mov loc5 = ar.ec |
207 | mov loc5 = ar.ec |
202 | mov loc6 = ar.ccv |
208 | mov loc6 = ar.ccv |
203 | mov loc7 = ar.csd |
209 | mov loc7 = ar.csd |
204 | mov loc8 = ar.ssd |
210 | mov loc8 = ar.ssd |
205 | 211 | ||
206 | mov loc9 = b0 |
212 | mov loc9 = b0 |
207 | mov loc10 = b1 |
213 | mov loc10 = b1 |
208 | mov loc11 = b2 |
214 | mov loc11 = b2 |
209 | mov loc12 = b3 |
215 | mov loc12 = b3 |
210 | mov loc13 = b4 |
216 | mov loc13 = b4 |
211 | mov loc14 = b5 |
217 | mov loc14 = b5 |
212 | mov loc15 = b6 |
218 | mov loc15 = b6 |
213 | mov loc16 = b7 |
219 | mov loc16 = b7 |
214 | 220 | ||
215 | /* 8. preserve general and floating-point registers */ |
221 | /* 8. preserve general and floating-point registers */ |
216 | /* TODO: save floating-point context */ |
222 | /* TODO: save floating-point context */ |
217 | mov loc17 = r1 |
223 | mov loc17 = r1 |
218 | mov loc18 = r2 |
224 | mov loc18 = r2 |
219 | mov loc19 = r3 |
225 | mov loc19 = r3 |
220 | mov loc20 = r4 |
226 | mov loc20 = r4 |
221 | mov loc21 = r5 |
227 | mov loc21 = r5 |
222 | mov loc22 = r6 |
228 | mov loc22 = r6 |
223 | mov loc23 = r7 |
229 | mov loc23 = r7 |
224 | mov loc24 = r8 |
230 | mov loc24 = r8 |
225 | mov loc25 = r9 |
231 | mov loc25 = r9 |
226 | mov loc26 = r10 |
232 | mov loc26 = r10 |
227 | mov loc27 = r11 |
233 | mov loc27 = r11 |
228 | /* skip r12 (stack pointer) */ |
234 | /* skip r12 (stack pointer) */ |
229 | mov loc28 = r13 |
235 | mov loc28 = r13 |
230 | mov loc29 = r14 |
236 | mov loc29 = r14 |
231 | mov loc30 = r15 |
237 | mov loc30 = r15 |
232 | mov loc31 = r16 |
238 | mov loc31 = r16 |
233 | mov loc32 = r17 |
239 | mov loc32 = r17 |
234 | mov loc33 = r18 |
240 | mov loc33 = r18 |
235 | mov loc34 = r19 |
241 | mov loc34 = r19 |
236 | mov loc35 = r20 |
242 | mov loc35 = r20 |
237 | mov loc36 = r21 |
243 | mov loc36 = r21 |
238 | mov loc37 = r22 |
244 | mov loc37 = r22 |
239 | mov loc38 = r23 |
245 | mov loc38 = r23 |
240 | mov loc39 = r24 |
246 | mov loc39 = r24 |
241 | mov loc40 = r25 |
247 | mov loc40 = r25 |
242 | mov loc41 = r26 |
248 | mov loc41 = r26 |
243 | mov loc42 = r27 |
249 | mov loc42 = r27 |
244 | mov loc43 = r28 |
250 | mov loc43 = r28 |
245 | mov loc44 = r29 |
251 | mov loc44 = r29 |
246 | mov loc45 = r30 |
252 | mov loc45 = r30 |
247 | mov loc46 = r31 |
253 | mov loc46 = r31 |
248 | 254 | ||
249 | /* 9. skipped (will not enable interrupts) */ |
255 | /* 9. skipped (will not enable interrupts) */ |
250 | /* |
256 | /* |
251 | * ssm PSR_I_MASK |
257 | * ssm PSR_I_MASK |
252 | * ;; |
258 | * ;; |
253 | * srlz.d |
259 | * srlz.d |
254 | */ |
260 | */ |
255 | 261 | ||
256 | /* 10. call handler */ |
262 | /* 10. call handler */ |
257 | mov b1 = loc2 |
263 | mov b1 = loc2 |
258 | br.call.sptk.many b0 = b1 |
264 | br.call.sptk.many b0 = b1 |
259 | 265 | ||
260 | /* 11. return from handler */ |
266 | /* 11. return from handler */ |
261 | 0: |
267 | 0: |
262 | 268 | ||
263 | /* 12. skipped (will not disable interrupts) */ |
269 | /* 12. skipped (will not disable interrupts) */ |
264 | /* |
270 | /* |
265 | * rsm PSR_I_MASK |
271 | * rsm PSR_I_MASK |
266 | * ;; |
272 | * ;; |
267 | * srlz.d |
273 | * srlz.d |
268 | */ |
274 | */ |
269 | 275 | ||
270 | /* 13. restore general and floating-point registers */ |
276 | /* 13. restore general and floating-point registers */ |
271 | /* TODO: restore floating-point context */ |
277 | /* TODO: restore floating-point context */ |
272 | mov r1 = loc17 |
278 | mov r1 = loc17 |
273 | mov r2 = loc18 |
279 | mov r2 = loc18 |
274 | mov r3 = loc19 |
280 | mov r3 = loc19 |
275 | mov r4 = loc20 |
281 | mov r4 = loc20 |
276 | mov r5 = loc21 |
282 | mov r5 = loc21 |
277 | mov r6 = loc22 |
283 | mov r6 = loc22 |
278 | mov r7 = loc23 |
284 | mov r7 = loc23 |
279 | mov r8 = loc24 |
285 | mov r8 = loc24 |
280 | mov r9 = loc25 |
286 | mov r9 = loc25 |
281 | mov r10 = loc26 |
287 | mov r10 = loc26 |
282 | mov r11 = loc27 |
288 | mov r11 = loc27 |
283 | /* skip r12 (stack pointer) */ |
289 | /* skip r12 (stack pointer) */ |
284 | mov r13 = loc28 |
290 | mov r13 = loc28 |
285 | mov r14 = loc29 |
291 | mov r14 = loc29 |
286 | mov r15 = loc30 |
292 | mov r15 = loc30 |
287 | mov r16 = loc31 |
293 | mov r16 = loc31 |
288 | mov r17 = loc32 |
294 | mov r17 = loc32 |
289 | mov r18 = loc33 |
295 | mov r18 = loc33 |
290 | mov r19 = loc34 |
296 | mov r19 = loc34 |
291 | mov r20 = loc35 |
297 | mov r20 = loc35 |
292 | mov r21 = loc36 |
298 | mov r21 = loc36 |
293 | mov r22 = loc37 |
299 | mov r22 = loc37 |
294 | mov r23 = loc38 |
300 | mov r23 = loc38 |
295 | mov r24 = loc39 |
301 | mov r24 = loc39 |
296 | mov r25 = loc40 |
302 | mov r25 = loc40 |
297 | mov r26 = loc41 |
303 | mov r26 = loc41 |
298 | mov r27 = loc42 |
304 | mov r27 = loc42 |
299 | mov r28 = loc43 |
305 | mov r28 = loc43 |
300 | mov r29 = loc44 |
306 | mov r29 = loc44 |
301 | mov r30 = loc45 |
307 | mov r30 = loc45 |
302 | mov r31 = loc46 |
308 | mov r31 = loc46 |
303 | 309 | ||
304 | /* 14. restore branch and application registers */ |
310 | /* 14. restore branch and application registers */ |
305 | mov ar.unat = loc3 |
311 | mov ar.unat = loc3 |
306 | mov ar.lc = loc4 |
312 | mov ar.lc = loc4 |
307 | mov ar.ec = loc5 |
313 | mov ar.ec = loc5 |
308 | mov ar.ccv = loc6 |
314 | mov ar.ccv = loc6 |
309 | mov ar.csd = loc7 |
315 | mov ar.csd = loc7 |
310 | mov ar.ssd = loc8 |
316 | mov ar.ssd = loc8 |
311 | 317 | ||
312 | mov b0 = loc9 |
318 | mov b0 = loc9 |
313 | mov b1 = loc10 |
319 | mov b1 = loc10 |
314 | mov b2 = loc11 |
320 | mov b2 = loc11 |
315 | mov b3 = loc12 |
321 | mov b3 = loc12 |
316 | mov b4 = loc13 |
322 | mov b4 = loc13 |
317 | mov b5 = loc14 |
323 | mov b5 = loc14 |
318 | mov b6 = loc15 |
324 | mov b6 = loc15 |
319 | mov b7 = loc16 |
325 | mov b7 = loc16 |
320 | 326 | ||
321 | /* 15. disable PSR.ic and switch to bank 0 */ |
327 | /* 15. disable PSR.ic and switch to bank 0 */ |
322 | rsm PSR_IC_MASK |
328 | rsm PSR_IC_MASK |
323 | bsw.0 ;; |
329 | bsw.0 ;; |
324 | srlz.d |
330 | srlz.d |
325 | 331 | ||
326 | mov r24 = loc1 |
332 | mov R_RET = loc1 |
327 | mov ar.pfs = loc0 |
333 | mov ar.pfs = loc0 |
328 | br.ret.sptk.many b0 |
334 | br.ret.sptk.many b0 |
329 | 335 | ||
330 | .global ivt |
336 | .global ivt |
331 | .align 32768 |
337 | .align 32768 |
332 | ivt: |
338 | ivt: |
333 | HEAVYWEIGHT_HANDLER 0x0000 |
339 | HEAVYWEIGHT_HANDLER 0x0000 |
334 | HEAVYWEIGHT_HANDLER 0x0400 |
340 | HEAVYWEIGHT_HANDLER 0x0400 |
335 | HEAVYWEIGHT_HANDLER 0x0800 |
341 | HEAVYWEIGHT_HANDLER 0x0800 |
336 | HEAVYWEIGHT_HANDLER 0x0c00 alternate_instruction_tlb_fault |
342 | HEAVYWEIGHT_HANDLER 0x0c00 alternate_instruction_tlb_fault |
337 | HEAVYWEIGHT_HANDLER 0x1000 alternate_data_tlb_fault |
343 | HEAVYWEIGHT_HANDLER 0x1000 alternate_data_tlb_fault |
338 | HEAVYWEIGHT_HANDLER 0x1400 data_nested_tlb_fault |
344 | HEAVYWEIGHT_HANDLER 0x1400 data_nested_tlb_fault |
339 | HEAVYWEIGHT_HANDLER 0x1800 |
345 | HEAVYWEIGHT_HANDLER 0x1800 |
340 | HEAVYWEIGHT_HANDLER 0x1c00 |
346 | HEAVYWEIGHT_HANDLER 0x1c00 |
341 | HEAVYWEIGHT_HANDLER 0x2000 data_dirty_bit_fault |
347 | HEAVYWEIGHT_HANDLER 0x2000 data_dirty_bit_fault |
342 | HEAVYWEIGHT_HANDLER 0x2400 instruction_access_bit_fault |
348 | HEAVYWEIGHT_HANDLER 0x2400 instruction_access_bit_fault |
343 | HEAVYWEIGHT_HANDLER 0x2800 data_access_bit_fault |
349 | HEAVYWEIGHT_HANDLER 0x2800 data_access_bit_fault |
344 | HEAVYWEIGHT_HANDLER 0x2c00 break_instruction |
350 | HEAVYWEIGHT_HANDLER 0x2c00 break_instruction |
345 | HEAVYWEIGHT_HANDLER 0x3000 external_interrupt /* For external interrupt, heavyweight handler is used. */ |
351 | HEAVYWEIGHT_HANDLER 0x3000 external_interrupt /* For external interrupt, heavyweight handler is used. */ |
346 | HEAVYWEIGHT_HANDLER 0x3400 |
352 | HEAVYWEIGHT_HANDLER 0x3400 |
347 | HEAVYWEIGHT_HANDLER 0x3800 |
353 | HEAVYWEIGHT_HANDLER 0x3800 |
348 | HEAVYWEIGHT_HANDLER 0x3c00 |
354 | HEAVYWEIGHT_HANDLER 0x3c00 |
349 | HEAVYWEIGHT_HANDLER 0x4000 |
355 | HEAVYWEIGHT_HANDLER 0x4000 |
350 | HEAVYWEIGHT_HANDLER 0x4400 |
356 | HEAVYWEIGHT_HANDLER 0x4400 |
351 | HEAVYWEIGHT_HANDLER 0x4800 |
357 | HEAVYWEIGHT_HANDLER 0x4800 |
352 | HEAVYWEIGHT_HANDLER 0x4c00 |
358 | HEAVYWEIGHT_HANDLER 0x4c00 |
353 | 359 | ||
354 | HEAVYWEIGHT_HANDLER 0x5000 page_not_present |
360 | HEAVYWEIGHT_HANDLER 0x5000 page_not_present |
355 | HEAVYWEIGHT_HANDLER 0x5100 |
361 | HEAVYWEIGHT_HANDLER 0x5100 |
356 | HEAVYWEIGHT_HANDLER 0x5200 |
362 | HEAVYWEIGHT_HANDLER 0x5200 |
357 | HEAVYWEIGHT_HANDLER 0x5300 |
363 | HEAVYWEIGHT_HANDLER 0x5300 |
358 | HEAVYWEIGHT_HANDLER 0x5400 general_exception |
364 | HEAVYWEIGHT_HANDLER 0x5400 general_exception |
359 | HEAVYWEIGHT_HANDLER 0x5500 |
365 | HEAVYWEIGHT_HANDLER 0x5500 |
360 | HEAVYWEIGHT_HANDLER 0x5600 |
366 | HEAVYWEIGHT_HANDLER 0x5600 |
361 | HEAVYWEIGHT_HANDLER 0x5700 |
367 | HEAVYWEIGHT_HANDLER 0x5700 |
362 | HEAVYWEIGHT_HANDLER 0x5800 |
368 | HEAVYWEIGHT_HANDLER 0x5800 |
363 | HEAVYWEIGHT_HANDLER 0x5900 |
369 | HEAVYWEIGHT_HANDLER 0x5900 |
364 | HEAVYWEIGHT_HANDLER 0x5a00 |
370 | HEAVYWEIGHT_HANDLER 0x5a00 |
365 | HEAVYWEIGHT_HANDLER 0x5b00 |
371 | HEAVYWEIGHT_HANDLER 0x5b00 |
366 | HEAVYWEIGHT_HANDLER 0x5c00 |
372 | HEAVYWEIGHT_HANDLER 0x5c00 |
367 | HEAVYWEIGHT_HANDLER 0x5d00 |
373 | HEAVYWEIGHT_HANDLER 0x5d00 |
368 | HEAVYWEIGHT_HANDLER 0x5e00 |
374 | HEAVYWEIGHT_HANDLER 0x5e00 |
369 | HEAVYWEIGHT_HANDLER 0x5f00 |
375 | HEAVYWEIGHT_HANDLER 0x5f00 |
370 | 376 | ||
371 | HEAVYWEIGHT_HANDLER 0x6000 |
377 | HEAVYWEIGHT_HANDLER 0x6000 |
372 | HEAVYWEIGHT_HANDLER 0x6100 |
378 | HEAVYWEIGHT_HANDLER 0x6100 |
373 | HEAVYWEIGHT_HANDLER 0x6200 |
379 | HEAVYWEIGHT_HANDLER 0x6200 |
374 | HEAVYWEIGHT_HANDLER 0x6300 |
380 | HEAVYWEIGHT_HANDLER 0x6300 |
375 | HEAVYWEIGHT_HANDLER 0x6400 |
381 | HEAVYWEIGHT_HANDLER 0x6400 |
376 | HEAVYWEIGHT_HANDLER 0x6500 |
382 | HEAVYWEIGHT_HANDLER 0x6500 |
377 | HEAVYWEIGHT_HANDLER 0x6600 |
383 | HEAVYWEIGHT_HANDLER 0x6600 |
378 | HEAVYWEIGHT_HANDLER 0x6700 |
384 | HEAVYWEIGHT_HANDLER 0x6700 |
379 | HEAVYWEIGHT_HANDLER 0x6800 |
385 | HEAVYWEIGHT_HANDLER 0x6800 |
380 | HEAVYWEIGHT_HANDLER 0x6900 |
386 | HEAVYWEIGHT_HANDLER 0x6900 |
381 | HEAVYWEIGHT_HANDLER 0x6a00 |
387 | HEAVYWEIGHT_HANDLER 0x6a00 |
382 | HEAVYWEIGHT_HANDLER 0x6b00 |
388 | HEAVYWEIGHT_HANDLER 0x6b00 |
383 | HEAVYWEIGHT_HANDLER 0x6c00 |
389 | HEAVYWEIGHT_HANDLER 0x6c00 |
384 | HEAVYWEIGHT_HANDLER 0x6d00 |
390 | HEAVYWEIGHT_HANDLER 0x6d00 |
385 | HEAVYWEIGHT_HANDLER 0x6e00 |
391 | HEAVYWEIGHT_HANDLER 0x6e00 |
386 | HEAVYWEIGHT_HANDLER 0x6f00 |
392 | HEAVYWEIGHT_HANDLER 0x6f00 |
387 | 393 | ||
388 | HEAVYWEIGHT_HANDLER 0x7000 |
394 | HEAVYWEIGHT_HANDLER 0x7000 |
389 | HEAVYWEIGHT_HANDLER 0x7100 |
395 | HEAVYWEIGHT_HANDLER 0x7100 |
390 | HEAVYWEIGHT_HANDLER 0x7200 |
396 | HEAVYWEIGHT_HANDLER 0x7200 |
391 | HEAVYWEIGHT_HANDLER 0x7300 |
397 | HEAVYWEIGHT_HANDLER 0x7300 |
392 | HEAVYWEIGHT_HANDLER 0x7400 |
398 | HEAVYWEIGHT_HANDLER 0x7400 |
393 | HEAVYWEIGHT_HANDLER 0x7500 |
399 | HEAVYWEIGHT_HANDLER 0x7500 |
394 | HEAVYWEIGHT_HANDLER 0x7600 |
400 | HEAVYWEIGHT_HANDLER 0x7600 |
395 | HEAVYWEIGHT_HANDLER 0x7700 |
401 | HEAVYWEIGHT_HANDLER 0x7700 |
396 | HEAVYWEIGHT_HANDLER 0x7800 |
402 | HEAVYWEIGHT_HANDLER 0x7800 |
397 | HEAVYWEIGHT_HANDLER 0x7900 |
403 | HEAVYWEIGHT_HANDLER 0x7900 |
398 | HEAVYWEIGHT_HANDLER 0x7a00 |
404 | HEAVYWEIGHT_HANDLER 0x7a00 |
399 | HEAVYWEIGHT_HANDLER 0x7b00 |
405 | HEAVYWEIGHT_HANDLER 0x7b00 |
400 | HEAVYWEIGHT_HANDLER 0x7c00 |
406 | HEAVYWEIGHT_HANDLER 0x7c00 |
401 | HEAVYWEIGHT_HANDLER 0x7d00 |
407 | HEAVYWEIGHT_HANDLER 0x7d00 |
402 | HEAVYWEIGHT_HANDLER 0x7e00 |
408 | HEAVYWEIGHT_HANDLER 0x7e00 |
403 | HEAVYWEIGHT_HANDLER 0x7f00 |
409 | HEAVYWEIGHT_HANDLER 0x7f00 |
404 | 410 |