Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / context / src / asm / jump_s390x_sysv_elf_gas.S
1 /*******************************************************
2 *                                                     *
3 *  -------------------------------------------------  *
4 *  |  0  |  1  |  2  |  3  |  4  |  5  |  6  |  7  |  *
5 *  -------------------------------------------------  *
6 *  |     0     |     8     |    16     |     24    |  *
7 *  -------------------------------------------------  *
8 *  |    R6     |    R7     |    R8     |    R9     |  *
9 *  -------------------------------------------------  *
10 *  -------------------------------------------------  *
11 *  |  8  |  9  |  10 |  11 |  12 |  13 |  14 |  15 |  *
12 *  -------------------------------------------------  *
13 *  |     32    |    40     |     48    |     56    |  *
14 *  -------------------------------------------------  *
15 *  |    R10    |    R11    |     R12   |     R13   |  *
16 *  -------------------------------------------------  *
17 *  -------------------------------------------------  *
18 *  |  16 |  17 |  18 |  19 |  20 |  21 |  22 |  23 |  *
19 *  -------------------------------------------------  *
20 *  |     64    |    72     |     80    |     88    |  *
21 *  -------------------------------------------------  *
22 *  |   R14/LR  |    R15    |     F1    |     F3    |  *
23 *  -------------------------------------------------  *
24 *  -------------------------------------------------  *
25 *  |  24 |  25 |  26 |  27 |  28 | 29  |           |  *
26 *  -------------------------------------------------  *
27 *  |     96    |    104    |    112    |    120    |  *
28 *  -------------------------------------------------  *
29 *  |    F5     |    F7     |     PC    |           |  *
30 *  -------------------------------------------------  *
31 * *****************************************************/
32
33 .file  "jump_s390x_sysv_elf_gas.S"
34 .text
35 .align  4 # According to the sample code in the ELF ABI docs
36 .global jump_fcontext
37 .type   jump_fcontext, @function
38
39 #define GR_OFFSET       0
40 #define LR_OFFSET       64
41 #define SP_OFFSET       72
42 #define FP_OFFSET       80
43 #define PC_OFFSET       112
44 #define L_CTX           120
45 #define L_STACKFRAME    120
46
47 jump_fcontext:
48     
49     # Reserved the space for stack to store the data of current context
50     # before we jump to the new context.
51     aghi %r15,-L_STACKFRAME
52
53     # save the registers to the stack
54     stmg %r6, %r15, GR_OFFSET(%r15)
55
56     # save the floating point registers
57     std  %f0,FP_OFFSET(%r15)
58     std  %f3,FP_OFFSET+8(%r15)
59     std  %f5,FP_OFFSET+16(%r15)
60     std  %f7,FP_OFFSET+24(%r15)
61
62     # Save LR as PC
63     stg  %r14,PC_OFFSET(%r15)
64
65     # Store the SP pointing to the old context-data into R0
66     lgr  %r0,%r15
67
68     # Get the SP pointing to the new context-data
69     # Note: Since the return type of the jump_fcontext is struct whose
70     # size is more than 8. The compiler automatically passes the 
71     # address of the transfer_t where the data needs to store into R2.
72
73     # Hence the first param passed to the jump_fcontext which represent
74     # the fctx we want to switch to is present in R3
75     # R2 --> Address of the return transfer_t struct
76     # R3 --> Context we want to switch to
77     # R4 --> Data
78     lgr %r15,%r3
79
80     # Load the registers with the data present in context-data of the
81     # context we are going to switch to
82     lmg %r6, %r14, GR_OFFSET(%r15)
83
84     # Restore Floating point registers
85     ld   %f1,FP_OFFSET(%r15)
86     ld   %f3,FP_OFFSET+8(%r15)
87     ld   %f5,FP_OFFSET+16(%r15)
88     ld   %f7,FP_OFFSET+24(%r15)
89
90     # Load PC
91     lg   %r1,PC_OFFSET(%r15)
92
93     # Adjust the stack 
94     aghi %r15,120
95
96     # R2 --> Address where the return transfer_t is stored
97     # R0 --> FCTX
98     # R4 --> DATA
99
100     # Store the elements to return transfer_t
101     stg %r15, 0(%r2)
102     stg %r4, 8(%r2)
103
104     # Note: The address in R2 points to the place where the return
105     # transfer_t is stored. Since context_function take transfer_t
106     # as first parameter. And R2 is the register which holds the
107     # first parameter value.
108
109     #jump to context
110     br  %r1
111
112 .size   jump_fcontext,.-jump_fcontext
113 # Mark that we don't need executable stack.
114 .section .note.GNU-stack,"",%progbits
115
116
117