]>
Commit | Line | Data |
---|---|---|
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 | * | F14 | F15 | F16 | F17 | * | |
16 | * ------------------------------------------------- * | |
17 | * ------------------------------------------------- * | |
18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * | |
19 | * ------------------------------------------------- * | |
20 | * | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | * | |
21 | * ------------------------------------------------- * | |
22 | * | F18 | F19 | F20 | F21 | * | |
23 | * ------------------------------------------------- * | |
24 | * ------------------------------------------------- * | |
25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * | |
26 | * ------------------------------------------------- * | |
27 | * | 64 | 68 | 72 | 76 | 80 | 84 | 88 | 92 | * | |
28 | * ------------------------------------------------- * | |
29 | * | F22 | F23 | F24 | F25 | * | |
30 | * ------------------------------------------------- * | |
31 | * ------------------------------------------------- * | |
32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * | |
33 | * ------------------------------------------------- * | |
34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * | |
35 | * ------------------------------------------------- * | |
36 | * | F26 | F27 | F28 | F29 | * | |
37 | * ------------------------------------------------- * | |
38 | * ------------------------------------------------- * | |
39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * | |
40 | * ------------------------------------------------- * | |
41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * | |
42 | * ------------------------------------------------- * | |
43 | * | F30 | F31 | fpscr | R13 | R14 | * | |
44 | * ------------------------------------------------- * | |
45 | * ------------------------------------------------- * | |
46 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * | |
47 | * ------------------------------------------------- * | |
48 | * | 160 | 164 | 168 | 172 | 176 | 180 | 184 | 188 | * | |
49 | * ------------------------------------------------- * | |
50 | * | R15 | R16 | R17 | R18 | R19 | R20 | R21 | R22 | * | |
51 | * ------------------------------------------------- * | |
52 | * ------------------------------------------------- * | |
53 | * | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | * | |
54 | * ------------------------------------------------- * | |
55 | * | 192 | 196 | 200 | 204 | 208 | 212 | 216 | 220 | * | |
56 | * ------------------------------------------------- * | |
57 | * | R23 | R24 | R25 | R26 | R27 | R28 | R29 | R30 | * | |
58 | * ------------------------------------------------- * | |
59 | * ------------------------------------------------- * | |
60 | * | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | * | |
61 | * ------------------------------------------------- * | |
62 | * | 224 | 228 | 232 | 236 | 240 | 244 | 248 | 252 | * | |
63 | * ------------------------------------------------- * | |
64 | * | R31 |hiddn| CR | LR | PC |bchai|linkr| FCTX| * | |
65 | * ------------------------------------------------- * | |
66 | * ------------------------------------------------- * | |
67 | * | 64 | | * | |
68 | * ------------------------------------------------- * | |
69 | * | 256 | | * | |
70 | * ------------------------------------------------- * | |
71 | * | DATA| | * | |
72 | * ------------------------------------------------- * | |
73 | * * | |
74 | *******************************************************/ | |
75 | ||
76 | .text | |
77 | .globl _make_fcontext | |
78 | .align 2 | |
79 | _make_fcontext: | |
80 | # save return address into R6 | |
81 | mflr r6 | |
82 | ||
83 | # first arg of make_fcontext() == top address of context-function | |
84 | # shift address in R3 to lower 16 byte boundary | |
85 | clrrwi r3, r3, 4 | |
86 | ||
87 | # reserve space for context-data on context-stack | |
88 | # including 64 byte of linkage + parameter area (R1 16 == 0) | |
89 | subi r3, r3, 336 | |
90 | ||
91 | # third arg of make_fcontext() == address of context-function | |
92 | stw r5, 240(r3) | |
93 | ||
94 | # set back-chain to zero | |
95 | li r0, 0 | |
96 | stw r0, 244(r3) | |
97 | ||
98 | mffs f0 # load FPSCR | |
99 | stfd f0, 144(r3) # save FPSCR | |
100 | ||
101 | # compute address of returned transfer_t | |
102 | addi r0, r3, 252 | |
103 | mr r4, r0 | |
104 | stw r4, 228(r3) | |
105 | ||
106 | # load LR | |
107 | mflr r0 | |
108 | # jump to label 1 | |
109 | bl 1f | |
110 | 1: | |
111 | # load LR into R4 | |
112 | mflr r4 | |
113 | # compute abs address of label finish | |
114 | addi r4, r4, finish - 1b | |
115 | # restore LR | |
116 | mtlr r0 | |
117 | # save address of finish as return-address for context-function | |
118 | # will be entered after context-function returns | |
119 | stw r4, 236(r3) | |
120 | ||
121 | # restore return address from R6 | |
122 | mtlr r6 | |
123 | ||
124 | blr # return pointer to context-data | |
125 | ||
126 | finish: | |
127 | # save return address into R0 | |
128 | mflr r0 | |
129 | # save return address on stack, set up stack frame | |
130 | stw r0, 4(r1) | |
131 | # allocate stack space, R1 16 == 0 | |
132 | stwu r1, -16(r1) | |
133 | ||
134 | # exit code is zero | |
135 | li r3, 0 | |
136 | # exit application | |
137 | bl _exit@plt |