Rev 915 | Rev 919 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 915 | Rev 916 | ||
---|---|---|---|
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 | #include <arch/mm/page.h> |
32 | #include <arch/mm/page.h> |
33 | #include <align.h> |
33 | #include <align.h> |
34 | 34 | ||
35 | #define STACK_ITEMS 14 |
35 | #define STACK_ITEMS 14 |
36 | #define STACK_FRAME_SIZE ALIGN_UP((STACK_ITEMS*STACK_ITEM_SIZE) + STACK_SCRATCH_AREA_SIZE, STACK_ALIGNMENT) |
36 | #define STACK_FRAME_SIZE ALIGN_UP((STACK_ITEMS*STACK_ITEM_SIZE) + STACK_SCRATCH_AREA_SIZE, STACK_ALIGNMENT) |
37 | 37 | ||
38 | #if (STACK_ITEMS % 2 == 0) |
38 | #if (STACK_ITEMS % 2 == 0) |
39 | # define STACK_FRAME_BIAS 8 |
39 | # define STACK_FRAME_BIAS 8 |
40 | #else |
40 | #else |
41 | # define STACK_FRAME_BIAS 16 |
41 | # define STACK_FRAME_BIAS 16 |
42 | #endif |
42 | #endif |
43 | 43 | ||
44 | /** Partitioning of bank 0 registers. */ |
44 | /** Partitioning of bank 0 registers. */ |
45 | #define R_OFFS r16 |
45 | #define R_OFFS r16 |
46 | #define R_HANDLER r17 |
46 | #define R_HANDLER r17 |
47 | #define R_RET r18 |
47 | #define R_RET r18 |
- | 48 | #define R_KSTACK_BSP r22 /* keep in sync with before_thread_runs_arch() */ |
|
48 | #define R_KSTACK r23 /* keep in sync with before_thread_runs_arch() */ |
49 | #define R_KSTACK r23 /* keep in sync with before_thread_runs_arch() */ |
49 | 50 | ||
50 | /** Heavyweight interrupt handler |
51 | /** Heavyweight interrupt handler |
51 | * |
52 | * |
52 | * This macro roughly follows steps from 1 to 19 described in |
53 | * This macro roughly follows steps from 1 to 19 described in |
53 | * Intel Itanium Architecture Software Developer's Manual, Chapter 3.4.2. |
54 | * Intel Itanium Architecture Software Developer's Manual, Chapter 3.4.2. |
54 | * |
55 | * |
55 | * HEAVYWEIGHT_HANDLER macro must cram into 16 bundles (48 instructions). |
56 | * HEAVYWEIGHT_HANDLER macro must cram into 16 bundles (48 instructions). |
56 | * This goal is achieved by using procedure calls after RSE becomes operational. |
57 | * This goal is achieved by using procedure calls after RSE becomes operational. |
57 | * |
58 | * |
58 | * Some steps are skipped (enabling and disabling interrupts). |
59 | * Some steps are skipped (enabling and disabling interrupts). |
59 | * Some steps are not fully supported yet (e.g. interruptions |
60 | * Some steps are not fully supported yet (e.g. dealing with floating-point |
60 | * from userspace and floating-point context). |
61 | * context). |
61 | * |
62 | * |
62 | * @param offs Offset from the beginning of IVT. |
63 | * @param offs Offset from the beginning of IVT. |
63 | * @param handler Interrupt handler address. |
64 | * @param handler Interrupt handler address. |
64 | */ |
65 | */ |
65 | .macro HEAVYWEIGHT_HANDLER offs, handler=universal_handler |
66 | .macro HEAVYWEIGHT_HANDLER offs, handler=universal_handler |
66 | .org ivt + \offs |
67 | .org ivt + \offs |
67 | mov R_OFFS = \offs |
68 | mov R_OFFS = \offs |
68 | movl R_HANDLER = \handler ;; |
69 | movl R_HANDLER = \handler ;; |
69 | br heavyweight_handler |
70 | br heavyweight_handler |
70 | .endm |
71 | .endm |
71 | 72 | ||
72 | .global heavyweight_handler |
73 | .global heavyweight_handler |
73 | heavyweight_handler: |
74 | heavyweight_handler: |
74 | /* 1. copy interrupt registers into bank 0 */ |
75 | /* 1. copy interrupt registers into bank 0 */ |
75 | 76 | ||
76 | /* |
77 | /* |
77 | * Note that r24-r31 from bank 0 can be used only as long as PSR.ic = 0. |
78 | * Note that r24-r31 from bank 0 can be used only as long as PSR.ic = 0. |
78 | */ |
79 | */ |
79 | mov r24 = cr.iip |
80 | mov r24 = cr.iip |
80 | mov r25 = cr.ipsr |
81 | mov r25 = cr.ipsr |
81 | mov r26 = cr.iipa |
82 | mov r26 = cr.iipa |
82 | mov r27 = cr.isr |
83 | mov r27 = cr.isr |
83 | mov r28 = cr.ifa |
84 | mov r28 = cr.ifa |
84 | 85 | ||
85 | /* 2. preserve predicate register into bank 0 */ |
86 | /* 2. preserve predicate register into bank 0 */ |
86 | mov r29 = pr ;; |
87 | mov r29 = pr ;; |
87 | 88 | ||
88 | /* 3. switch to kernel memory stack */ |
89 | /* 3. switch to kernel memory stack */ |
89 | mov r30 = cr.ipsr |
90 | mov r30 = cr.ipsr |
90 | shr.u r31 = r12, VRN_SHIFT ;; |
91 | shr.u r31 = r12, VRN_SHIFT ;; |
- | 92 | ||
- | 93 | shr.u r30 = r30, PSR_CPL_SHIFT ;; |
|
- | 94 | and r30 = PSR_CPL_MASK_SHIFTED, r30 ;; |
|
91 | 95 | ||
92 | /* |
96 | /* |
93 | * Set p6 to true if the stack register references kernel address space. |
97 | * Set p3 to true if the interrupted context executed in kernel mode. |
94 | * Set p7 to false if the stack register doesn't reference kernel address space. |
98 | * Set p4 to false if the interrupted context didn't execute in kernel mode. |
95 | */ |
99 | */ |
96 | cmp.eq p6, p7 = VRN_KERNEL, r31 ;; |
100 | cmp.eq p3, p4 = r30, r0 ;; |
97 | - | ||
98 | (p6) shr.u r30 = r30, PSR_CPL_SHIFT ;; |
- | |
99 | (p6) and r30 = PSR_CPL_MASK_SHIFTED, r30 ;; |
101 | cmp.eq p1, p2 = r30, r0 ;; /* remember IPSR setting in p1 and p2 */ |
100 | 102 | ||
101 | /* |
103 | /* |
102 | * Set p6 to true if the interrupted context executed in kernel mode. |
104 | * Set p3 to true if the stack register references kernel address space. |
103 | * Set p7 to false if the interrupted context didn't execute in kernel mode. |
105 | * Set p4 to false if the stack register doesn't reference kernel address space. |
104 | */ |
106 | */ |
105 | (p6) cmp.eq p6, p7 = r30, r0 ;; |
107 | (p3) cmp.eq p3, p4 = VRN_KERNEL, r31 ;; |
106 | 108 | ||
107 | /* |
109 | /* |
108 | * Now, p7 is true iff the stack needs to be switched to kernel stack. |
110 | * Now, p4 is true iff the stack needs to be switched to kernel stack. |
109 | */ |
111 | */ |
110 | mov r30 = r12 |
112 | mov r30 = r12 |
111 | (p7) mov r12 = R_KSTACK ;; |
113 | (p4) mov r12 = R_KSTACK ;; |
112 | 114 | ||
113 | add r31 = -STACK_FRAME_BIAS, r12 ;; |
115 | add r31 = -STACK_FRAME_BIAS, r12 ;; |
114 | add r12 = -STACK_FRAME_SIZE, r12 |
116 | add r12 = -STACK_FRAME_SIZE, r12 |
115 | 117 | ||
116 | /* 4. save registers in bank 0 into memory stack */ |
118 | /* 4. save registers in bank 0 into memory stack */ |
117 | st8 [r31] = r30, -8 ;; /* save old stack pointer */ |
119 | st8 [r31] = r30, -8 ;; /* save old stack pointer */ |
118 | 120 | ||
119 | st8 [r31] = r29, -8 ;; /* save predicate registers */ |
121 | st8 [r31] = r29, -8 ;; /* save predicate registers */ |
120 | 122 | ||
121 | st8 [r31] = r24, -8 ;; /* save cr.iip */ |
123 | st8 [r31] = r24, -8 ;; /* save cr.iip */ |
122 | st8 [r31] = r25, -8 ;; /* save cr.ipsr */ |
124 | st8 [r31] = r25, -8 ;; /* save cr.ipsr */ |
123 | st8 [r31] = r26, -8 ;; /* save cr.iipa */ |
125 | st8 [r31] = r26, -8 ;; /* save cr.iipa */ |
124 | st8 [r31] = r27, -8 ;; /* save cr.isr */ |
126 | st8 [r31] = r27, -8 ;; /* save cr.isr */ |
125 | st8 [r31] = r28, -8 ;; /* save cr.ifa */ |
127 | st8 [r31] = r28, -8 ;; /* save cr.ifa */ |
126 | 128 | ||
127 | /* 5. RSE switch from interrupted context */ |
129 | /* 5. RSE switch from interrupted context */ |
128 | mov r24 = ar.rsc |
130 | mov r24 = ar.rsc |
129 | mov r25 = ar.pfs |
131 | mov r25 = ar.pfs |
130 | cover |
132 | cover |
131 | mov r26 = cr.ifs |
133 | mov r26 = cr.ifs |
132 | 134 | ||
133 | st8 [r31] = r24, -8 ;; /* save ar.rsc */ |
135 | st8 [r31] = r24, -8 ;; /* save ar.rsc */ |
134 | st8 [r31] = r25, -8 ;; /* save ar.pfs */ |
136 | st8 [r31] = r25, -8 ;; /* save ar.pfs */ |
135 | st8 [r31] = r26, -8 /* save ar.ifs */ |
137 | st8 [r31] = r26, -8 /* save ar.ifs */ |
136 | 138 | ||
137 | and r30 = ~3, r24 ;; |
139 | and r30 = ~3, r24 ;; |
138 | mov ar.rsc = r30 ;; /* place RSE in enforced lazy mode */ |
140 | mov ar.rsc = r30 ;; /* place RSE in enforced lazy mode */ |
139 | 141 | ||
140 | mov r27 = ar.rnat |
142 | mov r27 = ar.rnat |
141 | mov r28 = ar.bspstore ;; |
143 | mov r28 = ar.bspstore ;; |
142 | 144 | ||
- | 145 | /* |
|
- | 146 | * Inspect BSPSTORE to figure out whether it is necessary to switch to kernel BSPSTORE. |
|
- | 147 | */ |
|
143 | /* assume kernel backing store */ |
148 | (p1) shr.u r30 = r28, VRN_SHIFT ;; |
- | 149 | (p1) cmp.eq p1, p2 = VRN_KERNEL, r30 ;; |
|
- | 150 | ||
- | 151 | /* |
|
- | 152 | * If BSPSTORE needs to be switched, p1 is false and p2 is true. |
|
- | 153 | */ |
|
- | 154 | (p1) mov r30 = r28 |
|
- | 155 | (p2) mov r30 = R_KSTACK_BSP ;; |
|
144 | mov ar.bspstore = r28 ;; |
156 | (p2) mov ar.bspstore = r30 ;; |
145 | 157 | ||
146 | mov r29 = ar.bsp |
158 | mov r29 = ar.bsp |
147 | 159 | ||
148 | st8 [r31] = r27, -8 ;; /* save ar.rnat */ |
160 | st8 [r31] = r27, -8 ;; /* save ar.rnat */ |
149 | st8 [r31] = r28, -8 ;; /* save new value written to ar.bspstore */ |
161 | st8 [r31] = r30, -8 ;; /* save new value written to ar.bspstore */ |
150 | st8 [r31] = r28, -8 ;; /* save ar.bspstore */ |
162 | st8 [r31] = r28, -8 ;; /* save ar.bspstore */ |
151 | st8 [r31] = r29, -8 /* save ar.bsp */ |
163 | st8 [r31] = r29, -8 /* save ar.bsp */ |
152 | 164 | ||
153 | mov ar.rsc = r24 /* restore RSE's setting */ |
165 | mov ar.rsc = r24 /* restore RSE's setting */ |
154 | 166 | ||
155 | /* steps 6 - 15 are done by heavyweight_handler_inner() */ |
167 | /* steps 6 - 15 are done by heavyweight_handler_inner() */ |
156 | mov R_RET = b0 /* save b0 belonging to interrupted context */ |
168 | mov R_RET = b0 /* save b0 belonging to interrupted context */ |
157 | br.call.sptk.many b0 = heavyweight_handler_inner |
169 | br.call.sptk.many b0 = heavyweight_handler_inner |
158 | 0: mov b0 = R_RET /* restore b0 belonging to the interrupted context */ |
170 | 0: mov b0 = R_RET /* restore b0 belonging to the interrupted context */ |
159 | 171 | ||
160 | /* 16. RSE switch to interrupted context */ |
172 | /* 16. RSE switch to interrupted context */ |
161 | cover /* allocate zerro size frame (step 1 (from Intel Docs)) */ |
173 | cover /* allocate zerro size frame (step 1 (from Intel Docs)) */ |
162 | 174 | ||
163 | add r31 = STACK_SCRATCH_AREA_SIZE, r12 ;; |
175 | add r31 = STACK_SCRATCH_AREA_SIZE, r12 ;; |
164 | 176 | ||
165 | ld8 r30 = [r31], +8 ;; /* load ar.bsp */ |
177 | ld8 r30 = [r31], +8 ;; /* load ar.bsp */ |
166 | ld8 r29 = [r31], +8 ;; /* load ar.bspstore */ |
178 | ld8 r29 = [r31], +8 ;; /* load ar.bspstore */ |
167 | ld8 r28 = [r31], +8 ;; /* load ar.bspstore_new */ |
179 | ld8 r28 = [r31], +8 ;; /* load ar.bspstore_new */ |
168 | sub r27 = r30 , r28 ;; /* calculate loadrs (step 2) */ |
180 | sub r27 = r30 , r28 ;; /* calculate loadrs (step 2) */ |
169 | shl r27 = r27, 16 |
181 | shl r27 = r27, 16 |
170 | 182 | ||
171 | mov r24 = ar.rsc ;; |
183 | mov r24 = ar.rsc ;; |
172 | and r30 = ~3, r24 ;; |
184 | and r30 = ~3, r24 ;; |
173 | or r24 = r30 , r27 ;; |
185 | or r24 = r30 , r27 ;; |
174 | mov ar.rsc = r24 ;; /* place RSE in enforced lazy mode */ |
186 | mov ar.rsc = r24 ;; /* place RSE in enforced lazy mode */ |
175 | 187 | ||
176 | loadrs /* (step 3) */ |
188 | loadrs /* (step 3) */ |
177 | 189 | ||
178 | ld8 r27 = [r31], +8 ;; /* load ar.rnat */ |
190 | ld8 r27 = [r31], +8 ;; /* load ar.rnat */ |
179 | ld8 r26 = [r31], +8 ;; /* load cr.ifs */ |
191 | ld8 r26 = [r31], +8 ;; /* load cr.ifs */ |
180 | ld8 r25 = [r31], +8 ;; /* load ar.pfs */ |
192 | ld8 r25 = [r31], +8 ;; /* load ar.pfs */ |
181 | ld8 r24 = [r31], +8 ;; /* load ar.rsc */ |
193 | ld8 r24 = [r31], +8 ;; /* load ar.rsc */ |
182 | 194 | ||
183 | mov ar.bspstore = r29 ;; /* (step 4) */ |
195 | mov ar.bspstore = r29 ;; /* (step 4) */ |
184 | mov ar.rnat = r27 /* (step 5) */ |
196 | mov ar.rnat = r27 /* (step 5) */ |
185 | 197 | ||
186 | mov ar.pfs = r25 /* (step 6) */ |
198 | mov ar.pfs = r25 /* (step 6) */ |
187 | mov cr.ifs = r26 |
199 | mov cr.ifs = r26 |
188 | 200 | ||
189 | mov ar.rsc = r24 /* (step 7) */ |
201 | mov ar.rsc = r24 /* (step 7) */ |
190 | 202 | ||
191 | /* 17. restore interruption state from memory stack */ |
203 | /* 17. restore interruption state from memory stack */ |
192 | ld8 r28 = [r31], +8 ;; /* load cr.ifa */ |
204 | ld8 r28 = [r31], +8 ;; /* load cr.ifa */ |
193 | ld8 r27 = [r31], +8 ;; /* load cr.isr */ |
205 | ld8 r27 = [r31], +8 ;; /* load cr.isr */ |
194 | ld8 r26 = [r31], +8 ;; /* load cr.iipa */ |
206 | ld8 r26 = [r31], +8 ;; /* load cr.iipa */ |
195 | ld8 r25 = [r31], +8 ;; /* load cr.ipsr */ |
207 | ld8 r25 = [r31], +8 ;; /* load cr.ipsr */ |
196 | ld8 r24 = [r31], +8 ;; /* load cr.iip */ |
208 | ld8 r24 = [r31], +8 ;; /* load cr.iip */ |
197 | 209 | ||
198 | mov cr.iip = r24 |
210 | mov cr.iip = r24 |
199 | mov cr.ipsr = r25 |
211 | mov cr.ipsr = r25 |
200 | mov cr.iipa = r26 |
212 | mov cr.iipa = r26 |
201 | mov cr.isr = r27 |
213 | mov cr.isr = r27 |
202 | mov cr.ifa = r28 |
214 | mov cr.ifa = r28 |
203 | 215 | ||
204 | /* 18. restore predicate registers from memory stack */ |
216 | /* 18. restore predicate registers from memory stack */ |
205 | ld8 r29 = [r31], +8 ;; /* load predicate registers */ |
217 | ld8 r29 = [r31], +8 ;; /* load predicate registers */ |
206 | mov pr = r29 |
218 | mov pr = r29 |
207 | 219 | ||
208 | /* 19. return from interruption */ |
220 | /* 19. return from interruption */ |
209 | ld8 r12 = [r31] /* load stack pointer */ |
221 | ld8 r12 = [r31] /* load stack pointer */ |
210 | rfi ;; |
222 | rfi ;; |
211 | 223 | ||
212 | .global heavyweight_handler_inner |
224 | .global heavyweight_handler_inner |
213 | heavyweight_handler_inner: |
225 | heavyweight_handler_inner: |
214 | /* |
226 | /* |
215 | * From this point, the rest of the interrupted context |
227 | * From this point, the rest of the interrupted context |
216 | * will be preserved in stacked registers and backing store. |
228 | * will be preserved in stacked registers and backing store. |
217 | */ |
229 | */ |
218 | alloc loc0 = ar.pfs, 0, 47, 2, 0 ;; |
230 | alloc loc0 = ar.pfs, 0, 47, 2, 0 ;; |
219 | 231 | ||
220 | /* bank 0 is going to be shadowed, copy essential data from there */ |
232 | /* bank 0 is going to be shadowed, copy essential data from there */ |
221 | mov loc1 = R_RET /* b0 belonging to interrupted context */ |
233 | mov loc1 = R_RET /* b0 belonging to interrupted context */ |
222 | mov loc2 = R_HANDLER |
234 | mov loc2 = R_HANDLER |
223 | mov out0 = R_OFFS |
235 | mov out0 = R_OFFS |
224 | 236 | ||
225 | add out1 = STACK_SCRATCH_AREA_SIZE, r12 |
237 | add out1 = STACK_SCRATCH_AREA_SIZE, r12 |
226 | 238 | ||
227 | /* 6. switch to bank 1 and reenable PSR.ic */ |
239 | /* 6. switch to bank 1 and reenable PSR.ic */ |
228 | ssm PSR_IC_MASK |
240 | ssm PSR_IC_MASK |
229 | bsw.1 ;; |
241 | bsw.1 ;; |
230 | srlz.d |
242 | srlz.d |
231 | 243 | ||
232 | /* 7. preserve branch and application registers */ |
244 | /* 7. preserve branch and application registers */ |
233 | mov loc3 = ar.unat |
245 | mov loc3 = ar.unat |
234 | mov loc4 = ar.lc |
246 | mov loc4 = ar.lc |
235 | mov loc5 = ar.ec |
247 | mov loc5 = ar.ec |
236 | mov loc6 = ar.ccv |
248 | mov loc6 = ar.ccv |
237 | mov loc7 = ar.csd |
249 | mov loc7 = ar.csd |
238 | mov loc8 = ar.ssd |
250 | mov loc8 = ar.ssd |
239 | 251 | ||
240 | mov loc9 = b0 |
252 | mov loc9 = b0 |
241 | mov loc10 = b1 |
253 | mov loc10 = b1 |
242 | mov loc11 = b2 |
254 | mov loc11 = b2 |
243 | mov loc12 = b3 |
255 | mov loc12 = b3 |
244 | mov loc13 = b4 |
256 | mov loc13 = b4 |
245 | mov loc14 = b5 |
257 | mov loc14 = b5 |
246 | mov loc15 = b6 |
258 | mov loc15 = b6 |
247 | mov loc16 = b7 |
259 | mov loc16 = b7 |
248 | 260 | ||
249 | /* 8. preserve general and floating-point registers */ |
261 | /* 8. preserve general and floating-point registers */ |
250 | /* TODO: save floating-point context */ |
262 | /* TODO: save floating-point context */ |
251 | mov loc17 = r1 |
263 | mov loc17 = r1 |
252 | mov loc18 = r2 |
264 | mov loc18 = r2 |
253 | mov loc19 = r3 |
265 | mov loc19 = r3 |
254 | mov loc20 = r4 |
266 | mov loc20 = r4 |
255 | mov loc21 = r5 |
267 | mov loc21 = r5 |
256 | mov loc22 = r6 |
268 | mov loc22 = r6 |
257 | mov loc23 = r7 |
269 | mov loc23 = r7 |
258 | mov loc24 = r8 |
270 | mov loc24 = r8 |
259 | mov loc25 = r9 |
271 | mov loc25 = r9 |
260 | mov loc26 = r10 |
272 | mov loc26 = r10 |
261 | mov loc27 = r11 |
273 | mov loc27 = r11 |
262 | /* skip r12 (stack pointer) */ |
274 | /* skip r12 (stack pointer) */ |
263 | mov loc28 = r13 |
275 | mov loc28 = r13 |
264 | mov loc29 = r14 |
276 | mov loc29 = r14 |
265 | mov loc30 = r15 |
277 | mov loc30 = r15 |
266 | mov loc31 = r16 |
278 | mov loc31 = r16 |
267 | mov loc32 = r17 |
279 | mov loc32 = r17 |
268 | mov loc33 = r18 |
280 | mov loc33 = r18 |
269 | mov loc34 = r19 |
281 | mov loc34 = r19 |
270 | mov loc35 = r20 |
282 | mov loc35 = r20 |
271 | mov loc36 = r21 |
283 | mov loc36 = r21 |
272 | mov loc37 = r22 |
284 | mov loc37 = r22 |
273 | mov loc38 = r23 |
285 | mov loc38 = r23 |
274 | mov loc39 = r24 |
286 | mov loc39 = r24 |
275 | mov loc40 = r25 |
287 | mov loc40 = r25 |
276 | mov loc41 = r26 |
288 | mov loc41 = r26 |
277 | mov loc42 = r27 |
289 | mov loc42 = r27 |
278 | mov loc43 = r28 |
290 | mov loc43 = r28 |
279 | mov loc44 = r29 |
291 | mov loc44 = r29 |
280 | mov loc45 = r30 |
292 | mov loc45 = r30 |
281 | mov loc46 = r31 |
293 | mov loc46 = r31 |
282 | 294 | ||
283 | /* 9. skipped (will not enable interrupts) */ |
295 | /* 9. skipped (will not enable interrupts) */ |
284 | /* |
296 | /* |
285 | * ssm PSR_I_MASK |
297 | * ssm PSR_I_MASK |
286 | * ;; |
298 | * ;; |
287 | * srlz.d |
299 | * srlz.d |
288 | */ |
300 | */ |
289 | 301 | ||
290 | /* 10. call handler */ |
302 | /* 10. call handler */ |
291 | mov b1 = loc2 |
303 | mov b1 = loc2 |
292 | br.call.sptk.many b0 = b1 |
304 | br.call.sptk.many b0 = b1 |
293 | 305 | ||
294 | /* 11. return from handler */ |
306 | /* 11. return from handler */ |
295 | 0: |
307 | 0: |
296 | 308 | ||
297 | /* 12. skipped (will not disable interrupts) */ |
309 | /* 12. skipped (will not disable interrupts) */ |
298 | /* |
310 | /* |
299 | * rsm PSR_I_MASK |
311 | * rsm PSR_I_MASK |
300 | * ;; |
312 | * ;; |
301 | * srlz.d |
313 | * srlz.d |
302 | */ |
314 | */ |
303 | 315 | ||
304 | /* 13. restore general and floating-point registers */ |
316 | /* 13. restore general and floating-point registers */ |
305 | /* TODO: restore floating-point context */ |
317 | /* TODO: restore floating-point context */ |
306 | mov r1 = loc17 |
318 | mov r1 = loc17 |
307 | mov r2 = loc18 |
319 | mov r2 = loc18 |
308 | mov r3 = loc19 |
320 | mov r3 = loc19 |
309 | mov r4 = loc20 |
321 | mov r4 = loc20 |
310 | mov r5 = loc21 |
322 | mov r5 = loc21 |
311 | mov r6 = loc22 |
323 | mov r6 = loc22 |
312 | mov r7 = loc23 |
324 | mov r7 = loc23 |
313 | mov r8 = loc24 |
325 | mov r8 = loc24 |
314 | mov r9 = loc25 |
326 | mov r9 = loc25 |
315 | mov r10 = loc26 |
327 | mov r10 = loc26 |
316 | mov r11 = loc27 |
328 | mov r11 = loc27 |
317 | /* skip r12 (stack pointer) */ |
329 | /* skip r12 (stack pointer) */ |
318 | mov r13 = loc28 |
330 | mov r13 = loc28 |
319 | mov r14 = loc29 |
331 | mov r14 = loc29 |
320 | mov r15 = loc30 |
332 | mov r15 = loc30 |
321 | mov r16 = loc31 |
333 | mov r16 = loc31 |
322 | mov r17 = loc32 |
334 | mov r17 = loc32 |
323 | mov r18 = loc33 |
335 | mov r18 = loc33 |
324 | mov r19 = loc34 |
336 | mov r19 = loc34 |
325 | mov r20 = loc35 |
337 | mov r20 = loc35 |
326 | mov r21 = loc36 |
338 | mov r21 = loc36 |
327 | mov r22 = loc37 |
339 | mov r22 = loc37 |
328 | mov r23 = loc38 |
340 | mov r23 = loc38 |
329 | mov r24 = loc39 |
341 | mov r24 = loc39 |
330 | mov r25 = loc40 |
342 | mov r25 = loc40 |
331 | mov r26 = loc41 |
343 | mov r26 = loc41 |
332 | mov r27 = loc42 |
344 | mov r27 = loc42 |
333 | mov r28 = loc43 |
345 | mov r28 = loc43 |
334 | mov r29 = loc44 |
346 | mov r29 = loc44 |
335 | mov r30 = loc45 |
347 | mov r30 = loc45 |
336 | mov r31 = loc46 |
348 | mov r31 = loc46 |
337 | 349 | ||
338 | /* 14. restore branch and application registers */ |
350 | /* 14. restore branch and application registers */ |
339 | mov ar.unat = loc3 |
351 | mov ar.unat = loc3 |
340 | mov ar.lc = loc4 |
352 | mov ar.lc = loc4 |
341 | mov ar.ec = loc5 |
353 | mov ar.ec = loc5 |
342 | mov ar.ccv = loc6 |
354 | mov ar.ccv = loc6 |
343 | mov ar.csd = loc7 |
355 | mov ar.csd = loc7 |
344 | mov ar.ssd = loc8 |
356 | mov ar.ssd = loc8 |
345 | 357 | ||
346 | mov b0 = loc9 |
358 | mov b0 = loc9 |
347 | mov b1 = loc10 |
359 | mov b1 = loc10 |
348 | mov b2 = loc11 |
360 | mov b2 = loc11 |
349 | mov b3 = loc12 |
361 | mov b3 = loc12 |
350 | mov b4 = loc13 |
362 | mov b4 = loc13 |
351 | mov b5 = loc14 |
363 | mov b5 = loc14 |
352 | mov b6 = loc15 |
364 | mov b6 = loc15 |
353 | mov b7 = loc16 |
365 | mov b7 = loc16 |
354 | 366 | ||
355 | /* 15. disable PSR.ic and switch to bank 0 */ |
367 | /* 15. disable PSR.ic and switch to bank 0 */ |
356 | rsm PSR_IC_MASK |
368 | rsm PSR_IC_MASK |
357 | bsw.0 ;; |
369 | bsw.0 ;; |
358 | srlz.d |
370 | srlz.d |
359 | 371 | ||
360 | mov R_RET = loc1 |
372 | mov R_RET = loc1 |
361 | mov ar.pfs = loc0 |
373 | mov ar.pfs = loc0 |
362 | br.ret.sptk.many b0 |
374 | br.ret.sptk.many b0 |
363 | 375 | ||
364 | .global ivt |
376 | .global ivt |
365 | .align 32768 |
377 | .align 32768 |
366 | ivt: |
378 | ivt: |
367 | HEAVYWEIGHT_HANDLER 0x0000 |
379 | HEAVYWEIGHT_HANDLER 0x0000 |
368 | HEAVYWEIGHT_HANDLER 0x0400 |
380 | HEAVYWEIGHT_HANDLER 0x0400 |
369 | HEAVYWEIGHT_HANDLER 0x0800 |
381 | HEAVYWEIGHT_HANDLER 0x0800 |
370 | HEAVYWEIGHT_HANDLER 0x0c00 alternate_instruction_tlb_fault |
382 | HEAVYWEIGHT_HANDLER 0x0c00 alternate_instruction_tlb_fault |
371 | HEAVYWEIGHT_HANDLER 0x1000 alternate_data_tlb_fault |
383 | HEAVYWEIGHT_HANDLER 0x1000 alternate_data_tlb_fault |
372 | HEAVYWEIGHT_HANDLER 0x1400 data_nested_tlb_fault |
384 | HEAVYWEIGHT_HANDLER 0x1400 data_nested_tlb_fault |
373 | HEAVYWEIGHT_HANDLER 0x1800 |
385 | HEAVYWEIGHT_HANDLER 0x1800 |
374 | HEAVYWEIGHT_HANDLER 0x1c00 |
386 | HEAVYWEIGHT_HANDLER 0x1c00 |
375 | HEAVYWEIGHT_HANDLER 0x2000 data_dirty_bit_fault |
387 | HEAVYWEIGHT_HANDLER 0x2000 data_dirty_bit_fault |
376 | HEAVYWEIGHT_HANDLER 0x2400 instruction_access_bit_fault |
388 | HEAVYWEIGHT_HANDLER 0x2400 instruction_access_bit_fault |
377 | HEAVYWEIGHT_HANDLER 0x2800 data_access_bit_fault |
389 | HEAVYWEIGHT_HANDLER 0x2800 data_access_bit_fault |
378 | HEAVYWEIGHT_HANDLER 0x2c00 break_instruction |
390 | HEAVYWEIGHT_HANDLER 0x2c00 break_instruction |
379 | HEAVYWEIGHT_HANDLER 0x3000 external_interrupt /* For external interrupt, heavyweight handler is used. */ |
391 | HEAVYWEIGHT_HANDLER 0x3000 external_interrupt /* For external interrupt, heavyweight handler is used. */ |
380 | HEAVYWEIGHT_HANDLER 0x3400 |
392 | HEAVYWEIGHT_HANDLER 0x3400 |
381 | HEAVYWEIGHT_HANDLER 0x3800 |
393 | HEAVYWEIGHT_HANDLER 0x3800 |
382 | HEAVYWEIGHT_HANDLER 0x3c00 |
394 | HEAVYWEIGHT_HANDLER 0x3c00 |
383 | HEAVYWEIGHT_HANDLER 0x4000 |
395 | HEAVYWEIGHT_HANDLER 0x4000 |
384 | HEAVYWEIGHT_HANDLER 0x4400 |
396 | HEAVYWEIGHT_HANDLER 0x4400 |
385 | HEAVYWEIGHT_HANDLER 0x4800 |
397 | HEAVYWEIGHT_HANDLER 0x4800 |
386 | HEAVYWEIGHT_HANDLER 0x4c00 |
398 | HEAVYWEIGHT_HANDLER 0x4c00 |
387 | 399 | ||
388 | HEAVYWEIGHT_HANDLER 0x5000 page_not_present |
400 | HEAVYWEIGHT_HANDLER 0x5000 page_not_present |
389 | HEAVYWEIGHT_HANDLER 0x5100 |
401 | HEAVYWEIGHT_HANDLER 0x5100 |
390 | HEAVYWEIGHT_HANDLER 0x5200 |
402 | HEAVYWEIGHT_HANDLER 0x5200 |
391 | HEAVYWEIGHT_HANDLER 0x5300 |
403 | HEAVYWEIGHT_HANDLER 0x5300 |
392 | HEAVYWEIGHT_HANDLER 0x5400 general_exception |
404 | HEAVYWEIGHT_HANDLER 0x5400 general_exception |
393 | HEAVYWEIGHT_HANDLER 0x5500 |
405 | HEAVYWEIGHT_HANDLER 0x5500 |
394 | HEAVYWEIGHT_HANDLER 0x5600 |
406 | HEAVYWEIGHT_HANDLER 0x5600 |
395 | HEAVYWEIGHT_HANDLER 0x5700 |
407 | HEAVYWEIGHT_HANDLER 0x5700 |
396 | HEAVYWEIGHT_HANDLER 0x5800 |
408 | HEAVYWEIGHT_HANDLER 0x5800 |
397 | HEAVYWEIGHT_HANDLER 0x5900 |
409 | HEAVYWEIGHT_HANDLER 0x5900 |
398 | HEAVYWEIGHT_HANDLER 0x5a00 |
410 | HEAVYWEIGHT_HANDLER 0x5a00 |
399 | HEAVYWEIGHT_HANDLER 0x5b00 |
411 | HEAVYWEIGHT_HANDLER 0x5b00 |
400 | HEAVYWEIGHT_HANDLER 0x5c00 |
412 | HEAVYWEIGHT_HANDLER 0x5c00 |
401 | HEAVYWEIGHT_HANDLER 0x5d00 |
413 | HEAVYWEIGHT_HANDLER 0x5d00 |
402 | HEAVYWEIGHT_HANDLER 0x5e00 |
414 | HEAVYWEIGHT_HANDLER 0x5e00 |
403 | HEAVYWEIGHT_HANDLER 0x5f00 |
415 | HEAVYWEIGHT_HANDLER 0x5f00 |
404 | 416 | ||
405 | HEAVYWEIGHT_HANDLER 0x6000 |
417 | HEAVYWEIGHT_HANDLER 0x6000 |
406 | HEAVYWEIGHT_HANDLER 0x6100 |
418 | HEAVYWEIGHT_HANDLER 0x6100 |
407 | HEAVYWEIGHT_HANDLER 0x6200 |
419 | HEAVYWEIGHT_HANDLER 0x6200 |
408 | HEAVYWEIGHT_HANDLER 0x6300 |
420 | HEAVYWEIGHT_HANDLER 0x6300 |
409 | HEAVYWEIGHT_HANDLER 0x6400 |
421 | HEAVYWEIGHT_HANDLER 0x6400 |
410 | HEAVYWEIGHT_HANDLER 0x6500 |
422 | HEAVYWEIGHT_HANDLER 0x6500 |
411 | HEAVYWEIGHT_HANDLER 0x6600 |
423 | HEAVYWEIGHT_HANDLER 0x6600 |
412 | HEAVYWEIGHT_HANDLER 0x6700 |
424 | HEAVYWEIGHT_HANDLER 0x6700 |
413 | HEAVYWEIGHT_HANDLER 0x6800 |
425 | HEAVYWEIGHT_HANDLER 0x6800 |
414 | HEAVYWEIGHT_HANDLER 0x6900 |
426 | HEAVYWEIGHT_HANDLER 0x6900 |
415 | HEAVYWEIGHT_HANDLER 0x6a00 |
427 | HEAVYWEIGHT_HANDLER 0x6a00 |
416 | HEAVYWEIGHT_HANDLER 0x6b00 |
428 | HEAVYWEIGHT_HANDLER 0x6b00 |
417 | HEAVYWEIGHT_HANDLER 0x6c00 |
429 | HEAVYWEIGHT_HANDLER 0x6c00 |
418 | HEAVYWEIGHT_HANDLER 0x6d00 |
430 | HEAVYWEIGHT_HANDLER 0x6d00 |
419 | HEAVYWEIGHT_HANDLER 0x6e00 |
431 | HEAVYWEIGHT_HANDLER 0x6e00 |
420 | HEAVYWEIGHT_HANDLER 0x6f00 |
432 | HEAVYWEIGHT_HANDLER 0x6f00 |
421 | 433 | ||
422 | HEAVYWEIGHT_HANDLER 0x7000 |
434 | HEAVYWEIGHT_HANDLER 0x7000 |
423 | HEAVYWEIGHT_HANDLER 0x7100 |
435 | HEAVYWEIGHT_HANDLER 0x7100 |
424 | HEAVYWEIGHT_HANDLER 0x7200 |
436 | HEAVYWEIGHT_HANDLER 0x7200 |
425 | HEAVYWEIGHT_HANDLER 0x7300 |
437 | HEAVYWEIGHT_HANDLER 0x7300 |
426 | HEAVYWEIGHT_HANDLER 0x7400 |
438 | HEAVYWEIGHT_HANDLER 0x7400 |
427 | HEAVYWEIGHT_HANDLER 0x7500 |
439 | HEAVYWEIGHT_HANDLER 0x7500 |
428 | HEAVYWEIGHT_HANDLER 0x7600 |
440 | HEAVYWEIGHT_HANDLER 0x7600 |
429 | HEAVYWEIGHT_HANDLER 0x7700 |
441 | HEAVYWEIGHT_HANDLER 0x7700 |
430 | HEAVYWEIGHT_HANDLER 0x7800 |
442 | HEAVYWEIGHT_HANDLER 0x7800 |
431 | HEAVYWEIGHT_HANDLER 0x7900 |
443 | HEAVYWEIGHT_HANDLER 0x7900 |
432 | HEAVYWEIGHT_HANDLER 0x7a00 |
444 | HEAVYWEIGHT_HANDLER 0x7a00 |
433 | HEAVYWEIGHT_HANDLER 0x7b00 |
445 | HEAVYWEIGHT_HANDLER 0x7b00 |
434 | HEAVYWEIGHT_HANDLER 0x7c00 |
446 | HEAVYWEIGHT_HANDLER 0x7c00 |
435 | HEAVYWEIGHT_HANDLER 0x7d00 |
447 | HEAVYWEIGHT_HANDLER 0x7d00 |
436 | HEAVYWEIGHT_HANDLER 0x7e00 |
448 | HEAVYWEIGHT_HANDLER 0x7e00 |
437 | HEAVYWEIGHT_HANDLER 0x7f00 |
449 | HEAVYWEIGHT_HANDLER 0x7f00 |
438 | 450 |