]>
Commit | Line | Data |
---|---|---|
92f5a8d4 TL |
1 | /* |
2 | Copyright Jiaxun Yang 2018. | |
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 | 8 | 16 | 24 | * | |
14 | * ------------------------------------------------- * | |
15 | * | F24 | F25 | F26 | F27 | * | |
16 | * ------------------------------------------------- * | |
17 | * ------------------------------------------------- * | |
18 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * | |
19 | * ------------------------------------------------- * | |
20 | * | 32 | 40 | 48 | 56 | * | |
21 | * ------------------------------------------------- * | |
22 | * | F28 | F29 | F30 | F31 | * | |
23 | * ------------------------------------------------- * | |
24 | * ------------------------------------------------- * | |
25 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * | |
26 | * ------------------------------------------------- * | |
27 | * | 64 | 72 | 80 | 88 | * | |
28 | * ------------------------------------------------- * | |
29 | * | S0 | S1 | S2 | S3 | * | |
30 | * ------------------------------------------------- * | |
31 | * ------------------------------------------------- * | |
32 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * | |
33 | * ------------------------------------------------- * | |
34 | * | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | * | |
35 | * ------------------------------------------------- * | |
36 | * | S4 | S5 | S6 | S7 | * | |
37 | * ------------------------------------------------- * | |
38 | * ------------------------------------------------- * | |
39 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * | |
40 | * ------------------------------------------------- * | |
41 | * | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | * | |
42 | * ------------------------------------------------- * | |
43 | * | FP | GP | RA | PC | * | |
44 | * ------------------------------------------------- * | |
45 | * * | |
46 | * *****************************************************/ | |
47 | ||
48 | .file "make_mips64_n64_elf_gas.S" | |
49 | .text | |
50 | .globl make_fcontext | |
51 | .align 2 | |
52 | .type make_fcontext,@function | |
53 | .ent make_fcontext | |
54 | make_fcontext: | |
55 | #ifdef __PIC__ | |
56 | .set noreorder | |
57 | .cpload $t9 | |
58 | .set reorder | |
59 | #endif | |
60 | # shift address in A0 to lower 16 byte boundary | |
61 | li $v1, 0xfffffffffffffff0 | |
62 | and $v0, $v1, $a0 | |
63 | ||
64 | # reserve space for context-data on context-stack | |
65 | daddiu $v0, $v0, -160 | |
66 | ||
67 | # third arg of make_fcontext() == address of context-function | |
68 | sd $a2, 152($v0) | |
69 | # save global pointer in context-data | |
70 | sd $gp, 136($v0) | |
71 | ||
72 | # psudo instruction compute abs address of label finish based on GP | |
73 | dla $t9, finish | |
74 | ||
75 | # save address of finish as return-address for context-function | |
76 | # will be entered after context-function returns | |
77 | sd $t9, 144($v0) | |
78 | ||
79 | jr $ra # return pointer to context-data | |
80 | ||
81 | finish: | |
82 | # reload our gp register (needed for la) | |
83 | daddiu $t0, $sp, -160 | |
84 | ld $gp, 136($t0) | |
85 | ||
86 | # call _exit(0) | |
87 | # the previous function should have left the 16 bytes incoming argument | |
88 | # area on the stack which we reuse for calling _exit | |
89 | dla $t9, _exit | |
90 | move $a0, $zero | |
91 | jr $t9 | |
92 | .end make_fcontext | |
93 | .size make_fcontext, .-make_fcontext | |
94 | ||
95 | /* Mark that we don't need executable stack. */ | |
96 | .section .note.GNU-stack,"",%progbits |