Imported Upstream version 1.72.0
[platform/upstream/boost.git] / libs / context / src / asm / ontop_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  "ontop_s390x_sysv_elf_gas.S"
34 .text
35 .align  4 # According to the sample code in the ELF ABI docs
36 .global ontop_fcontext
37 .type   ontop_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
46 ontop_fcontext:
47     
48     # Reserved the space for stack to store the data of current context
49     # before we jump to the new context.
50     aghi %r15,-L_CTX
51
52     # save the registers to the stack
53     stmg %r6, %r15, GR_OFFSET(%r15)
54
55     # save the floating point registers
56     std  %f0,FP_OFFSET(%r15)
57     std  %f3,FP_OFFSET+8(%r15)
58     std  %f5,FP_OFFSET+16(%r15)
59     std  %f7,FP_OFFSET+24(%r15)
60     # Save LR as PC
61     stg  %r14,PC_OFFSET(%r15)
62
63     # Store the SP pointing to the old context-data into R0
64     lgr  %r0,%r15
65
66     # Get the SP pointing to the new context-data
67     # Note: Since the return type of the jump_fcontext is struct whose
68     # size is more than 8. The compiler automatically passes the 
69     # address of the transfer_t where the data needs to store into R2.
70
71     # Hence the first param passed to the jump_fcontext which represent
72     # the fctx we want to switch to is present in R3
73     # R2 --> Address of the return transfer_t struct
74     # R3 --> Context we want to switch to
75     # R4 --> Data
76     lgr  %r15,%r3
77
78     # Load the registers with the data present in context-data of the
79     # context we are going to switch to
80     lmg  %r6,%r15,GR_OFFSET(%r15)
81
82     # Restore Floating point registers
83     ld   %f1,FP_OFFSET(%r15)
84     ld   %f3,FP_OFFSET+8(%r15)
85     ld   %f5,FP_OFFSET+16(%r15)
86     ld   %f7,FP_OFFSET+24(%r15)
87
88     # Skip PC
89
90     # Adjust the stack
91     aghi %r15,L_CTX
92
93     # R2 --> Address where the return transfer_t is stored
94     # R0 --> FCTX
95     # R4 --> DATA
96     # R5 --> Context function
97
98     # Store the elements to return transfer_t
99     stg  %r15, 0(%r2)
100     stg  %r4, 8(%r2)
101
102     # Note: The address in R2 points to the place where the return
103     # transfer_t is stored. Since context_function take transfer_t
104     # as first parameter. And R2 is the register which holds the
105     # first parameter value.
106
107     #jump to context function
108     br  %r5
109
110 .size   ontop_fcontext,.-ontop_fcontext
111 # Mark that we don't need executable stack.
112 .section .note.GNU-stack,"",%progbits