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)
8 /*******************************************************
10 * ------------------------------------------------- *
11 * | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
12 * ------------------------------------------------- *
13 * |bchai|hiddn| fpscr | PC | CR | R14 | R15 | *
14 * ------------------------------------------------- *
15 * ------------------------------------------------- *
16 * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
17 * ------------------------------------------------- *
18 * | R16 | R17 | R18 | R19 | R20 | R21 | R22 | R23 | *
19 * ------------------------------------------------- *
20 * ------------------------------------------------- *
21 * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | *
22 * ------------------------------------------------- *
23 * | R24 | R25 | R26 | R27 | R28 | R29 | R30 | R31 | *
24 * ------------------------------------------------- *
25 * ------------------------------------------------- *
26 * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
27 * ------------------------------------------------- *
28 * | F14 | F15 | F16 | F17 | *
29 * ------------------------------------------------- *
30 * ------------------------------------------------- *
31 * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
32 * ------------------------------------------------- *
33 * | F18 | F19 | F20 | F21 | *
34 * ------------------------------------------------- *
35 * ------------------------------------------------- *
36 * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | *
37 * ------------------------------------------------- *
38 * | F22 | F23 | F24 | F25 | *
39 * ------------------------------------------------- *
40 * ------------------------------------------------- *
41 * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | *
42 * ------------------------------------------------- *
43 * | F26 | F27 | F28 | F29 | *
44 * ------------------------------------------------- *
45 * ------------------------|------------ *
46 * | 224 | 228 | 232 | 236 | 240 | 244 | *
47 * ------------------------|------------ *
48 * | F30 | F31 |bchai| LR | *
49 * ------------------------|------------ *
51 *******************************************************/
53 .file "ontop_ppc32_sysv_elf_gas.S"
57 .type ontop_fcontext,@function
59 # Linux: ontop_fcontext( hidden transfer_t * R3, R4, R5, R6)
60 # Other: transfer_t R3:R4 = jump_fcontext( R3, R4, R5)
62 mflr %r0 # return address from LR
64 mfcr %r8 # condition register
66 stwu %r1, -240(%r1) # allocate stack space, R1 % 16 == 0
67 stw %r0, 244(%r1) # save LR in caller's frame
70 stw %r3, 4(%r1) # hidden pointer
73 stfd %f0, 8(%r1) # FPSCR
74 stw %r0, 16(%r1) # LR as PC
77 # Save registers R14 to R31.
78 # Don't change R2, the thread-local storage pointer.
79 # Don't change R13, the small data pointer.
99 # Save registers F14 to F31 in slots with 8-byte alignment.
100 # 4-byte alignment may stall the pipeline of some processors.
101 # Less than 4 may cause alignment traps.
121 # store RSP (pointing to context-data) in R7/R6
122 # restore RSP (pointing to context-data) from R4/R3
126 lwz %r3, 4(%r1) # hidden pointer
132 # ignore PC at 16(%r1)
133 lfd %f0, 8(%r1) # FPSCR
134 lwz %r8, 20(%r1) # CR
136 mtfsf 0xff, %f0 # restore FPSCR
137 mtcr %r8 # restore CR
179 # restore LR from caller's frame
186 # see tail_ppc32_sysv_elf_gas.cpp
187 # Linux: fcontext_ontop_tail( hidden transfer_t * R3, R4, R5, R6, R7)
188 # Other: transfer_t R3:R4 = fcontext_ontop_tail( R3, R4, R5, R6)
189 b ontop_fcontext_tail
190 .size ontop_fcontext, .-ontop_fcontext
192 /* Mark that we don't need executable stack. */
193 .section .note.GNU-stack,"",%progbits