]>
Commit | Line | Data |
---|---|---|
7c673cae FG |
1 | /* |
2 | Copyright Oliver Kowalke 2009. | |
3 | Distributed under the Boost Software License, Version 1.0. | |
4 | (See accompanying file LICENSE_1_0.txt or copy at | |
5 | http://www.boost.org/LICENSE_1_0.txt) | |
6 | */ | |
7 | ||
8 | /******************************************************* | |
9 | * * | |
10 | * ------------------------------------------------- * | |
11 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * | |
12 | * ------------------------------------------------- * | |
13 | * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | * | |
14 | * ------------------------------------------------- * | |
15 | * | TOC | R14 | R15 | R16 | * | |
16 | * ------------------------------------------------- * | |
17 | * ------------------------------------------------- * | |
18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * | |
19 | * ------------------------------------------------- * | |
20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * | |
21 | * ------------------------------------------------- * | |
22 | * | R17 | R18 | R19 | R20 | * | |
23 | * ------------------------------------------------- * | |
24 | * ------------------------------------------------- * | |
25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * | |
26 | * ------------------------------------------------- * | |
27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * | |
28 | * ------------------------------------------------- * | |
29 | * | R21 | R22 | R23 | R24 | * | |
30 | * ------------------------------------------------- * | |
31 | * ------------------------------------------------- * | |
32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * | |
33 | * ------------------------------------------------- * | |
34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * | |
35 | * ------------------------------------------------- * | |
36 | * | R25 | R26 | R27 | R28 | * | |
37 | * ------------------------------------------------- * | |
38 | * ------------------------------------------------- * | |
39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * | |
40 | * ------------------------------------------------- * | |
41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * | |
42 | * ------------------------------------------------- * | |
43 | * | R29 | R30 | R31 | hidden | * | |
44 | * ------------------------------------------------- * | |
45 | * ------------------------------------------------- * | |
46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * | |
47 | * ------------------------------------------------- * | |
48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * | |
49 | * ------------------------------------------------- * | |
50 | * | CR | LR | PC | back-chain| * | |
51 | * ------------------------------------------------- * | |
52 | * ------------------------------------------------- * | |
53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * | |
54 | * ------------------------------------------------- * | |
55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * | |
56 | * ------------------------------------------------- * | |
57 | * | cr saved | lr saved | compiler | linker | * | |
58 | * ------------------------------------------------- * | |
59 | * ------------------------------------------------- * | |
60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * | |
61 | * ------------------------------------------------- * | |
62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * | |
63 | * ------------------------------------------------- * | |
64 | * | TOC saved | FCTX | DATA | | * | |
65 | * ------------------------------------------------- * | |
66 | * * | |
67 | *******************************************************/ | |
68 | ||
69 | .globl ontop_fcontext | |
70 | #if _CALL_ELF == 2 | |
71 | .text | |
72 | .align 2 | |
73 | ontop_fcontext: | |
74 | addis %r2, %r12, .TOC.-ontop_fcontext@ha | |
75 | addi %r2, %r2, .TOC.-ontop_fcontext@l | |
76 | .localentry ontop_fcontext, . - ontop_fcontext | |
77 | #else | |
78 | .section ".opd","aw" | |
79 | .align 3 | |
80 | ontop_fcontext: | |
81 | # ifdef _CALL_LINUX | |
82 | .quad .L.ontop_fcontext,.TOC.@tocbase,0 | |
83 | .type ontop_fcontext,@function | |
84 | .text | |
85 | .align 2 | |
86 | .L.ontop_fcontext: | |
87 | # else | |
88 | .hidden .ontop_fcontext | |
89 | .globl .ontop_fcontext | |
90 | .quad .ontop_fcontext,.TOC.@tocbase,0 | |
91 | .size ontop_fcontext,24 | |
92 | .type .ontop_fcontext,@function | |
93 | .text | |
94 | .align 2 | |
95 | .ontop_fcontext: | |
96 | # endif | |
97 | #endif | |
98 | # reserve space on stack | |
99 | subi %r1, %r1, 184 | |
100 | ||
101 | #if _CALL_ELF != 2 | |
102 | std %r2, 0(%r1) # save TOC | |
103 | #endif | |
104 | std %r14, 8(%r1) # save R14 | |
105 | std %r15, 16(%r1) # save R15 | |
106 | std %r16, 24(%r1) # save R16 | |
107 | std %r17, 32(%r1) # save R17 | |
108 | std %r18, 40(%r1) # save R18 | |
109 | std %r19, 48(%r1) # save R19 | |
110 | std %r20, 56(%r1) # save R20 | |
111 | std %r21, 64(%r1) # save R21 | |
112 | std %r22, 72(%r1) # save R22 | |
113 | std %r23, 80(%r1) # save R23 | |
114 | std %r24, 88(%r1) # save R24 | |
115 | std %r25, 96(%r1) # save R25 | |
116 | std %r26, 104(%r1) # save R26 | |
117 | std %r27, 112(%r1) # save R27 | |
118 | std %r29, 120(%r1) # save R28 | |
119 | std %r29, 128(%r1) # save R29 | |
120 | std %r30, 136(%r1) # save R30 | |
121 | std %r31, 144(%r1) # save R31 | |
122 | std %r3, 152(%r1) # save hidden | |
123 | ||
124 | # save CR | |
125 | mfcr %r0 | |
126 | std %r0, 160(%r1) | |
127 | # save LR | |
128 | mflr %r0 | |
129 | std %r0, 168(%r1) | |
130 | # save LR as PC | |
131 | std %r0, 176(%r1) | |
132 | ||
133 | # store RSP (pointing to context-data) in R7 | |
134 | mr %r7, %r1 | |
135 | ||
136 | # restore RSP (pointing to context-data) from R4 | |
137 | mr %r1, %r4 | |
138 | ||
139 | #if _CALL_ELF != 2 | |
140 | ld %r2, 0(%r1) # restore TOC | |
141 | #endif | |
142 | ld %r14, 8(%r1) # restore R14 | |
143 | ld %r15, 16(%r1) # restore R15 | |
144 | ld %r16, 24(%r1) # restore R16 | |
145 | ld %r17, 32(%r1) # restore R17 | |
146 | ld %r18, 40(%r1) # restore R18 | |
147 | ld %r19, 48(%r1) # restore R19 | |
148 | ld %r20, 56(%r1) # restore R20 | |
149 | ld %r21, 64(%r1) # restore R21 | |
150 | ld %r22, 72(%r1) # restore R22 | |
151 | ld %r23, 80(%r1) # restore R23 | |
152 | ld %r24, 88(%r1) # restore R24 | |
153 | ld %r25, 96(%r1) # restore R25 | |
154 | ld %r26, 104(%r1) # restore R26 | |
155 | ld %r27, 112(%r1) # restore R27 | |
156 | ld %r28, 120(%r1) # restore R28 | |
157 | ld %r29, 128(%r1) # restore R29 | |
158 | ld %r30, 136(%r1) # restore R30 | |
159 | ld %r31, 144(%r1) # restore R31 | |
160 | ld %r4, 152(%r1) # restore hidden | |
161 | ||
162 | # restore CR | |
163 | ld %r0, 160(%r1) | |
164 | mtcr %r0 | |
165 | # restore LR | |
166 | ld %r0, 168(%r1) | |
167 | mtlr %r0 | |
168 | # ignore PC | |
169 | ||
170 | # adjust stack | |
171 | addi %r1, %r1, 184 | |
172 | ||
173 | # return transfer_t | |
174 | std %r7, 0(%r4) | |
175 | std %r5, 8(%r4) | |
176 | ||
177 | # restore CTR | |
178 | mtctr %r6 | |
179 | ||
180 | # jump to context | |
181 | bctr | |
182 | #if _CALL_ELF == 2 | |
183 | .size ontop_fcontext, .-ontop_fcontext | |
184 | #else | |
185 | # ifdef _CALL_LINUX | |
186 | .size .ontop_fcontext, .-.L.ontop_fcontext | |
187 | # else | |
188 | .size .ontop_fcontext, .-.ontop_fcontext | |
189 | # endif | |
190 | #endif | |
191 | ||
192 | ||
193 | /* Mark that we don't need executable stack. */ | |
194 | .section .note.GNU-stack,"",%progbits |