Rev 919 | Rev 962 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 919 | Rev 921 | ||
---|---|---|---|
Line 30... | Line 30... | ||
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 18 |
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 |
Line 43... | Line 43... | ||
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_TMP r19 |
|
48 | #define R_KSTACK_BSP r22 /* keep in sync with before_thread_runs_arch() */ |
49 | #define R_KSTACK_BSP r22 /* keep in sync with before_thread_runs_arch() */ |
49 | #define R_KSTACK r23 /* keep in sync with before_thread_runs_arch() */ |
50 | #define R_KSTACK r23 /* keep in sync with before_thread_runs_arch() */ |
50 | 51 | ||
51 | /** Heavyweight interrupt handler |
52 | /** Heavyweight interrupt handler |
52 | * |
53 | * |
Line 102... | Line 103... | ||
102 | 103 | ||
103 | /* |
104 | /* |
104 | * Set p3 to true if the stack register references kernel address space. |
105 | * Set p3 to true if the stack register references kernel address space. |
105 | * Set p4 to false if the stack register doesn't reference kernel address space. |
106 | * Set p4 to false if the stack register doesn't reference kernel address space. |
106 | */ |
107 | */ |
107 | (p3) cmp.eq p3, p4 = VRN_KERNEL, r31 ;; |
108 | (p3) cmp.eq p3, p4 = VRN_KERNEL, r31 ;; |
108 | 109 | ||
109 | /* |
110 | /* |
110 | * Now, p4 is true iff the stack needs to be switched to kernel stack. |
111 | * Now, p4 is true iff the stack needs to be switched to kernel stack. |
111 | */ |
112 | */ |
112 | mov r30 = r12 |
113 | mov r30 = r12 |
113 | (p4) mov r12 = R_KSTACK ;; |
114 | (p4) mov r12 = R_KSTACK ;; |
114 | 115 | ||
115 | add r31 = -STACK_FRAME_BIAS, r12 ;; |
116 | add r31 = -STACK_FRAME_BIAS, r12 ;; |
116 | add r12 = -STACK_FRAME_SIZE, r12 |
117 | add r12 = -STACK_FRAME_SIZE, r12 |
117 | 118 | ||
118 | /* 4. save registers in bank 0 into memory stack */ |
119 | /* 4. save registers in bank 0 into memory stack */ |
- | 120 | ||
- | 121 | /* |
|
- | 122 | * If this is break_instruction handler, |
|
- | 123 | * copy input parameters to stack. |
|
- | 124 | */ |
|
- | 125 | mov R_TMP = 0x2c00 ;; |
|
- | 126 | cmp.eq p6,p5 = R_OFFS, R_TMP ;; |
|
- | 127 | ||
- | 128 | /* |
|
- | 129 | * From now on, if this is break_instruction handler, p6 is true and p5 is false. |
|
- | 130 | * Otherwise p6 is false and p5 is true. |
|
- | 131 | * Note that p5 is a preserved predicate register and we make use of it. |
|
- | 132 | */ |
|
- | 133 | ||
- | 134 | (p6) st8 [r31] = r35, -8 ;; /* save in3 */ |
|
- | 135 | (p6) st8 [r31] = r34, -8 ;; /* save in2 */ |
|
- | 136 | (p6) st8 [r31] = r33, -8 ;; /* save in1 */ |
|
- | 137 | (p6) st8 [r31] = r32, -8 ;; /* save in0 */ |
|
- | 138 | (p5) add r31 = -32, r31 ;; |
|
- | 139 | ||
119 | st8 [r31] = r30, -8 ;; /* save old stack pointer */ |
140 | st8 [r31] = r30, -8 ;; /* save old stack pointer */ |
120 | 141 | ||
121 | st8 [r31] = r29, -8 ;; /* save predicate registers */ |
142 | st8 [r31] = r29, -8 ;; /* save predicate registers */ |
122 | 143 | ||
123 | st8 [r31] = r24, -8 ;; /* save cr.iip */ |
144 | st8 [r31] = r24, -8 ;; /* save cr.iip */ |
Line 144... | Line 165... | ||
144 | mov r28 = ar.bspstore ;; |
165 | mov r28 = ar.bspstore ;; |
145 | 166 | ||
146 | /* |
167 | /* |
147 | * Inspect BSPSTORE to figure out whether it is necessary to switch to kernel BSPSTORE. |
168 | * Inspect BSPSTORE to figure out whether it is necessary to switch to kernel BSPSTORE. |
148 | */ |
169 | */ |
149 | (p1) shr.u r30 = r28, VRN_SHIFT ;; |
170 | (p1) shr.u r30 = r28, VRN_SHIFT ;; |
150 | (p1) cmp.eq p1, p2 = VRN_KERNEL, r30 ;; |
171 | (p1) cmp.eq p1, p2 = VRN_KERNEL, r30 ;; |
151 | 172 | ||
152 | /* |
173 | /* |
153 | * If BSPSTORE needs to be switched, p1 is false and p2 is true. |
174 | * If BSPSTORE needs to be switched, p1 is false and p2 is true. |
154 | */ |
175 | */ |
155 | (p1) mov r30 = r28 |
176 | (p1) mov r30 = r28 |
156 | (p2) mov r30 = R_KSTACK_BSP ;; |
177 | (p2) mov r30 = R_KSTACK_BSP ;; |
157 | (p2) mov ar.bspstore = r30 ;; |
178 | (p2) mov ar.bspstore = r30 ;; |
158 | 179 | ||
159 | mov r29 = ar.bsp |
180 | mov r29 = ar.bsp |
160 | 181 | ||
161 | st8 [r31] = r27, -8 ;; /* save ar.rnat */ |
182 | st8 [r31] = r27, -8 ;; /* save ar.rnat */ |
162 | st8 [r31] = r30, -8 ;; /* save new value written to ar.bspstore */ |
183 | st8 [r31] = r30, -8 ;; /* save new value written to ar.bspstore */ |
Line 266... | Line 287... | ||
266 | mov loc19 = r3 |
287 | mov loc19 = r3 |
267 | mov loc20 = r4 |
288 | mov loc20 = r4 |
268 | mov loc21 = r5 |
289 | mov loc21 = r5 |
269 | mov loc22 = r6 |
290 | mov loc22 = r6 |
270 | mov loc23 = r7 |
291 | mov loc23 = r7 |
271 | mov loc24 = r8 |
292 | (p5) mov loc24 = r8 /* only if not in break_instruction handler */ |
272 | mov loc25 = r9 |
293 | mov loc25 = r9 |
273 | mov loc26 = r10 |
294 | mov loc26 = r10 |
274 | mov loc27 = r11 |
295 | mov loc27 = r11 |
275 | /* skip r12 (stack pointer) */ |
296 | /* skip r12 (stack pointer) */ |
276 | mov loc28 = r13 |
297 | mov loc28 = r13 |
Line 323... | Line 344... | ||
323 | mov r3 = loc19 |
344 | mov r3 = loc19 |
324 | mov r4 = loc20 |
345 | mov r4 = loc20 |
325 | mov r5 = loc21 |
346 | mov r5 = loc21 |
326 | mov r6 = loc22 |
347 | mov r6 = loc22 |
327 | mov r7 = loc23 |
348 | mov r7 = loc23 |
328 | mov r8 = loc24 |
349 | (p5) mov r8 = loc24 /* only if not in break_instruction handler */ |
329 | mov r9 = loc25 |
350 | mov r9 = loc25 |
330 | mov r10 = loc26 |
351 | mov r10 = loc26 |
331 | mov r11 = loc27 |
352 | mov r11 = loc27 |
332 | /* skip r12 (stack pointer) */ |
353 | /* skip r12 (stack pointer) */ |
333 | mov r13 = loc28 |
354 | mov r13 = loc28 |