]>
Commit | Line | Data |
---|---|---|
92f5a8d4 | 1 | /******************************************************* |
f67539c2 TL |
2 | * ------------------------------------------------- * |
3 | * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | * | |
4 | * ------------------------------------------------- * | |
5 | * | 0 | 8 | 16 | 24 | * | |
6 | * ------------------------------------------------- * | |
7 | * | t.fctx | t.data | r2 | r6 | * | |
8 | * ------------------------------------------------- * | |
9 | * ------------------------------------------------- * | |
10 | * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | * | |
11 | * ------------------------------------------------- * | |
12 | * | 32 | 40 | 48 | 56 | * | |
13 | * ------------------------------------------------- * | |
14 | * | r7 | r8 | r9 | r10 | * | |
15 | * ------------------------------------------------- * | |
16 | * ------------------------------------------------- * | |
17 | * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | * | |
18 | * ------------------------------------------------- * | |
19 | * | 64 | 72 | 80 | 88 | * | |
20 | * ------------------------------------------------- * | |
21 | * | r11 | r12 | r13 | r14 | * | |
22 | * ------------------------------------------------- * | |
23 | * ------------------------------------------------- * | |
24 | * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | * | |
25 | * ------------------------------------------------- * | |
26 | * | 96 | 104 | 112 | 120 | * | |
27 | * ------------------------------------------------- * | |
28 | * | f8 | f9 | f10 | f11 | * | |
29 | * ------------------------------------------------- * | |
30 | * ------------------------------------------------- * | |
31 | * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | * | |
32 | * ------------------------------------------------- * | |
33 | * | 128 | 136 | 144 | 152 | * | |
34 | * ------------------------------------------------- * | |
35 | * | f12 | f13 | f14 | f15 | * | |
36 | * ------------------------------------------------- * | |
37 | * ------------------------------------------------- * | |
38 | * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | * | |
39 | * ------------------------------------------------- * | |
40 | * | 160 | 168 | 176 | | * | |
41 | * ------------------------------------------------- * | |
42 | * | fpc | pc | | | * | |
43 | * ------------------------------------------------- * | |
44 | *******************************************************/ | |
45 | ||
92f5a8d4 | 46 | .text |
f67539c2 TL |
47 | .align 8 |
48 | .global make_fcontext | |
49 | .type make_fcontext, @function | |
92f5a8d4 | 50 | |
f67539c2 TL |
51 | #define ARG_OFFSET 0 |
52 | #define GR_OFFSET 16 | |
53 | #define R14_OFFSET 88 | |
54 | #define FP_OFFSET 96 | |
55 | #define FPC_OFFSET 160 | |
56 | #define PC_OFFSET 168 | |
57 | #define CONTEXT_SIZE 176 | |
92f5a8d4 | 58 | |
f67539c2 | 59 | /* |
92f5a8d4 | 60 | |
f67539c2 | 61 | fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) ); |
92f5a8d4 | 62 | |
f67539c2 | 63 | Create and return a context below SP to call FN. |
92f5a8d4 | 64 | |
f67539c2 TL |
65 | Incoming args |
66 | r2 - The stack location where to create the context | |
67 | r3 - The size of the context | |
68 | r4 - The address of the context function | |
92f5a8d4 | 69 | |
f67539c2 | 70 | */ |
92f5a8d4 | 71 | |
f67539c2 TL |
72 | make_fcontext: |
73 | .machine "z10" | |
74 | /* Align the stack to an 8 byte boundary. */ | |
75 | nill %r2,0xfff0 | |
92f5a8d4 | 76 | |
f67539c2 TL |
77 | /* Allocate stack space for the context. */ |
78 | aghi %r2,-CONTEXT_SIZE | |
92f5a8d4 | 79 | |
f67539c2 TL |
80 | /* Set the r2 save slot to zero. This indicates jump_fcontext |
81 | that this is a special context. */ | |
82 | mvghi GR_OFFSET(%r2),0 | |
92f5a8d4 | 83 | |
f67539c2 TL |
84 | /* Save the floating point control register. */ |
85 | stfpc FPC_OFFSET(%r2) | |
92f5a8d4 | 86 | |
f67539c2 TL |
87 | /* Store the address of the target function as new pc. */ |
88 | stg %r4,PC_OFFSET(%r2) | |
92f5a8d4 | 89 | |
f67539c2 TL |
90 | /* Store a pointer to the finish routine as r14. If a function |
91 | called via context routines just returns that value will be | |
92 | loaded and used as return address. Hence the program will | |
93 | just exit. */ | |
94 | larl %r1,finish | |
95 | stg %r1,R14_OFFSET(%r2) | |
92f5a8d4 | 96 | |
f67539c2 TL |
97 | /* Return as usual with the new context returned in r2. */ |
98 | br %r14 | |
99 | ||
100 | finish: | |
101 | /* In finish tasks, you load the exit code and exit the | |
102 | make_fcontext This is called when the context-function is | |
103 | entirely executed. */ | |
104 | lghi %r2,0 | |
105 | brasl %r14,_exit@PLT | |
92f5a8d4 TL |
106 | |
107 | .size make_fcontext,.-make_fcontext | |
92f5a8d4 | 108 | .section .note.GNU-stack,"",%progbits |