|
|
62e5e2 |
From f60b86bddcf964f1a97df7a33aa36bc0160dba38 Mon Sep 17 00:00:00 2001
|
|
|
62e5e2 |
From: Andreas Krebbel <krebbel@linux.ibm.com>
|
|
|
62e5e2 |
Date: Mon, 23 Mar 2020 09:09:17 +0100
|
|
|
62e5e2 |
Subject: [PATCH 4/4] IBM Z: Fix fcontext routines
|
|
|
62e5e2 |
|
|
|
62e5e2 |
---
|
|
|
62e5e2 |
src/asm/jump_s390x_sysv_elf_gas.S | 257 +++++++++++++++++------------
|
|
|
62e5e2 |
src/asm/make_s390x_sysv_elf_gas.S | 176 ++++++++++----------
|
|
|
62e5e2 |
src/asm/ontop_s390x_sysv_elf_gas.S | 238 ++++++++++++++------------
|
|
|
62e5e2 |
3 files changed, 374 insertions(+), 297 deletions(-)
|
|
|
62e5e2 |
|
|
|
62e5e2 |
diff --git a/src/asm/jump_s390x_sysv_elf_gas.S b/src/asm/jump_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
index b2163cc..c2a578b 100644
|
|
|
62e5e2 |
--- a/libs/context/src/asm/jump_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
+++ b/libs/context/src/asm/jump_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
@@ -1,117 +1,156 @@
|
|
|
62e5e2 |
/*******************************************************
|
|
|
62e5e2 |
-* *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 0 | 8 | 16 | 24 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R6 | R7 | R8 | R9 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 32 | 40 | 48 | 56 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R10 | R11 | R12 | R13 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 64 | 72 | 80 | 88 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R14/LR | R15 | F1 | F3 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 24 | 25 | 26 | 27 | 28 | 29 | | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 96 | 104 | 112 | 120 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | F5 | F7 | PC | | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* *****************************************************/
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
-.file "jump_s390x_sysv_elf_gas.S"
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 0 | 8 | 16 | 24 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | t.fctx | t.data | r2 | r6 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 32 | 40 | 48 | 56 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | r7 | r8 | r9 | r10 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 64 | 72 | 80 | 88 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | r11 | r12 | r13 | r14 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 96 | 104 | 112 | 120 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | f8 | f9 | f10 | f11 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 128 | 136 | 144 | 152 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | f12 | f13 | f14 | f15 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 160 | 168 | 176 | | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | fpc | pc | | | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ *******************************************************/
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
.text
|
|
|
62e5e2 |
-.align 4 # According to the sample code in the ELF ABI docs
|
|
|
62e5e2 |
-.global jump_fcontext
|
|
|
62e5e2 |
-.type jump_fcontext, @function
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
-#define GR_OFFSET 0
|
|
|
62e5e2 |
-#define LR_OFFSET 64
|
|
|
62e5e2 |
-#define SP_OFFSET 72
|
|
|
62e5e2 |
-#define FP_OFFSET 80
|
|
|
62e5e2 |
-#define PC_OFFSET 112
|
|
|
62e5e2 |
-#define L_CTX 120
|
|
|
62e5e2 |
-#define L_STACKFRAME 120
|
|
|
62e5e2 |
+.align 8
|
|
|
62e5e2 |
+.global jump_fcontext
|
|
|
62e5e2 |
+.type jump_fcontext, @function
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+#define ARG_OFFSET 0
|
|
|
62e5e2 |
+#define GR_OFFSET 16
|
|
|
62e5e2 |
+#define FP_OFFSET 96
|
|
|
62e5e2 |
+#define FPC_OFFSET 160
|
|
|
62e5e2 |
+#define PC_OFFSET 168
|
|
|
62e5e2 |
+#define CONTEXT_SIZE 176
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+#define REG_SAVE_AREA_SIZE 160
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+/*
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+typedef void* fcontext_t;
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+struct transfer_t {
|
|
|
62e5e2 |
+ fcontext_t fctx;
|
|
|
62e5e2 |
+ void * data;
|
|
|
62e5e2 |
+};
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+transfer_t jump_fcontext( fcontext_t const to,
|
|
|
62e5e2 |
+ void * data);
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+Incoming args
|
|
|
62e5e2 |
+r2 - Hidden argument to the location where the return transfer_t needs to be returned
|
|
|
62e5e2 |
+r3 - Context we want to switch to
|
|
|
62e5e2 |
+r4 - Data pointer
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+*/
|
|
|
62e5e2 |
|
|
|
62e5e2 |
jump_fcontext:
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Reserved the space for stack to store the data of current context
|
|
|
62e5e2 |
- # before we jump to the new context.
|
|
|
62e5e2 |
- aghi %r15,-L_STACKFRAME
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # save the registers to the stack
|
|
|
62e5e2 |
- stmg %r6, %r15, GR_OFFSET(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # save the floating point registers
|
|
|
62e5e2 |
- std %f0,FP_OFFSET(%r15)
|
|
|
62e5e2 |
- std %f3,FP_OFFSET+8(%r15)
|
|
|
62e5e2 |
- std %f5,FP_OFFSET+16(%r15)
|
|
|
62e5e2 |
- std %f7,FP_OFFSET+24(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Save LR as PC
|
|
|
62e5e2 |
- stg %r14,PC_OFFSET(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Store the SP pointing to the old context-data into R0
|
|
|
62e5e2 |
- lgr %r0,%r15
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Get the SP pointing to the new context-data
|
|
|
62e5e2 |
- # Note: Since the return type of the jump_fcontext is struct whose
|
|
|
62e5e2 |
- # size is more than 8. The compiler automatically passes the
|
|
|
62e5e2 |
- # address of the transfer_t where the data needs to store into R2.
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Hence the first param passed to the jump_fcontext which represent
|
|
|
62e5e2 |
- # the fctx we want to switch to is present in R3
|
|
|
62e5e2 |
- # R2 --> Address of the return transfer_t struct
|
|
|
62e5e2 |
- # R3 --> Context we want to switch to
|
|
|
62e5e2 |
- # R4 --> Data
|
|
|
62e5e2 |
- lgr %r15,%r3
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Load the registers with the data present in context-data of the
|
|
|
62e5e2 |
- # context we are going to switch to
|
|
|
62e5e2 |
- lmg %r6, %r14, GR_OFFSET(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Restore Floating point registers
|
|
|
62e5e2 |
- ld %f1,FP_OFFSET(%r15)
|
|
|
62e5e2 |
- ld %f3,FP_OFFSET+8(%r15)
|
|
|
62e5e2 |
- ld %f5,FP_OFFSET+16(%r15)
|
|
|
62e5e2 |
- ld %f7,FP_OFFSET+24(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Load PC
|
|
|
62e5e2 |
- lg %r1,PC_OFFSET(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Adjust the stack
|
|
|
62e5e2 |
- aghi %r15,120
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # R2 --> Address where the return transfer_t is stored
|
|
|
62e5e2 |
- # R0 --> FCTX
|
|
|
62e5e2 |
- # R4 --> DATA
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Store the elements to return transfer_t
|
|
|
62e5e2 |
- stg %r15, 0(%r2)
|
|
|
62e5e2 |
- stg %r4, 8(%r2)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Note: The address in R2 points to the place where the return
|
|
|
62e5e2 |
- # transfer_t is stored. Since context_function take transfer_t
|
|
|
62e5e2 |
- # as first parameter. And R2 is the register which holds the
|
|
|
62e5e2 |
- # first parameter value.
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- #jump to context
|
|
|
62e5e2 |
- br %r1
|
|
|
62e5e2 |
+ .machine "z10"
|
|
|
62e5e2 |
+ /* Reserve stack space to store the current context. */
|
|
|
62e5e2 |
+ aghi %r15,-CONTEXT_SIZE
|
|
|
62e5e2 |
|
|
|
62e5e2 |
-.size jump_fcontext,.-jump_fcontext
|
|
|
62e5e2 |
-# Mark that we don't need executable stack.
|
|
|
62e5e2 |
-.section .note.GNU-stack,"",%progbits
|
|
|
62e5e2 |
+ /* Save the argument register holding the location of the return value. */
|
|
|
62e5e2 |
+ stg %r2,GR_OFFSET(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Save the call-saved general purpose registers. */
|
|
|
62e5e2 |
+ stmg %r6,%r14,GR_OFFSET+8(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Save call-saved floating point registers. */
|
|
|
62e5e2 |
+ std %f8,FP_OFFSET(%r15)
|
|
|
62e5e2 |
+ std %f9,FP_OFFSET+8(%r15)
|
|
|
62e5e2 |
+ std %f10,FP_OFFSET+16(%r15)
|
|
|
62e5e2 |
+ std %f11,FP_OFFSET+24(%r15)
|
|
|
62e5e2 |
+ std %f12,FP_OFFSET+32(%r15)
|
|
|
62e5e2 |
+ std %f13,FP_OFFSET+40(%r15)
|
|
|
62e5e2 |
+ std %f14,FP_OFFSET+48(%r15)
|
|
|
62e5e2 |
+ std %f15,FP_OFFSET+56(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Save the return address as current pc. */
|
|
|
62e5e2 |
+ stg %r14,PC_OFFSET(%r15)
|
|
|
62e5e2 |
|
|
|
62e5e2 |
+ /* Save the floating point control register. */
|
|
|
62e5e2 |
+ stfpc FPC_OFFSET(%r15)
|
|
|
62e5e2 |
|
|
|
62e5e2 |
+ /* Backup the stack pointer pointing to the old context-data into r1. */
|
|
|
62e5e2 |
+ lgr %r1,%r15
|
|
|
62e5e2 |
|
|
|
62e5e2 |
+ /* Load the new context pointer as stack pointer. */
|
|
|
62e5e2 |
+ lgr %r15,%r3
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Restore the call-saved GPRs from the new context. */
|
|
|
62e5e2 |
+ lmg %r6,%r14,GR_OFFSET+8(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Restore call-saved floating point registers. */
|
|
|
62e5e2 |
+ ld %f8,FP_OFFSET(%r15)
|
|
|
62e5e2 |
+ ld %f9,FP_OFFSET+8(%r15)
|
|
|
62e5e2 |
+ ld %f10,FP_OFFSET+16(%r15)
|
|
|
62e5e2 |
+ ld %f11,FP_OFFSET+24(%r15)
|
|
|
62e5e2 |
+ ld %f12,FP_OFFSET+32(%r15)
|
|
|
62e5e2 |
+ ld %f13,FP_OFFSET+40(%r15)
|
|
|
62e5e2 |
+ ld %f14,FP_OFFSET+48(%r15)
|
|
|
62e5e2 |
+ ld %f15,FP_OFFSET+56(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Load the floating point control register. */
|
|
|
62e5e2 |
+ lfpc FPC_OFFSET(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Restore PC - the location where we will jump to at the end. */
|
|
|
62e5e2 |
+ lg %r5,PC_OFFSET(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ ltg %r2,GR_OFFSET(%r15)
|
|
|
62e5e2 |
+ jnz use_return_slot
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* We restore a make_fcontext context. Use the function
|
|
|
62e5e2 |
+ argument slot in the context we just saved and allocate the
|
|
|
62e5e2 |
+ register save area for the target function. */
|
|
|
62e5e2 |
+ la %r2,ARG_OFFSET(%r1)
|
|
|
62e5e2 |
+ aghi %r15,-REG_SAVE_AREA_SIZE
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+use_return_slot:
|
|
|
62e5e2 |
+ /* Save the two fields in transfer_t. When calling a
|
|
|
62e5e2 |
+ make_fcontext function this becomes the function argument of
|
|
|
62e5e2 |
+ the target function, otherwise it will be the return value of
|
|
|
62e5e2 |
+ jump_fcontext. */
|
|
|
62e5e2 |
+ stg %r1,0(%r2)
|
|
|
62e5e2 |
+ stg %r4,8(%r2)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Free the restored context. */
|
|
|
62e5e2 |
+ aghi %r15,CONTEXT_SIZE
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Jump to the PC loaded from the new context. */
|
|
|
62e5e2 |
+ br %r5
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+.size jump_fcontext,.-jump_fcontext
|
|
|
62e5e2 |
+.section .note.GNU-stack,"",%progbits
|
|
|
62e5e2 |
diff --git a/src/asm/make_s390x_sysv_elf_gas.S b/src/asm/make_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
index d02856c..e7e2d5f 100644
|
|
|
62e5e2 |
--- a/libs/context/src/asm/make_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
+++ b/libs/context/src/asm/make_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
@@ -1,104 +1,108 @@
|
|
|
62e5e2 |
/*******************************************************
|
|
|
62e5e2 |
-* *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 0 | 8 | 16 | 24 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R6 | R7 | R8 | R9 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 32 | 40 | 48 | 56 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R10 | R11 | R12 | R13 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 64 | 72 | 80 | 88 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R14/LR | R15 | F1 | F3 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 24 | 25 | 26 | 27 | 28 | 29 | | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 96 | 104 | 112 | 120 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | F5 | F7 | PC | | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* *****************************************************/
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
-.file "make_s390x_sysv_elf_gas.S"
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 0 | 8 | 16 | 24 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | t.fctx | t.data | r2 | r6 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 32 | 40 | 48 | 56 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | r7 | r8 | r9 | r10 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 64 | 72 | 80 | 88 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | r11 | r12 | r13 | r14 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 96 | 104 | 112 | 120 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | f8 | f9 | f10 | f11 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 128 | 136 | 144 | 152 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | f12 | f13 | f14 | f15 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 160 | 168 | 176 | | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | fpc | pc | | | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ *******************************************************/
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
.text
|
|
|
62e5e2 |
-.align 4 # According to the sample code in the ELF ABI docs
|
|
|
62e5e2 |
-.global make_fcontext
|
|
|
62e5e2 |
-.type make_fcontext, @function
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
-#define GR_OFFSET 0
|
|
|
62e5e2 |
-#define LR_OFFSET 64
|
|
|
62e5e2 |
-#define SP_OFFSET 72
|
|
|
62e5e2 |
-#define FP_OFFSET 80
|
|
|
62e5e2 |
-#define PC_OFFSET 112
|
|
|
62e5e2 |
-#define L_CTX 120
|
|
|
62e5e2 |
-#define L_STACKFRAME 120
|
|
|
62e5e2 |
+.align 8
|
|
|
62e5e2 |
+.global make_fcontext
|
|
|
62e5e2 |
+.type make_fcontext, @function
|
|
|
62e5e2 |
|
|
|
62e5e2 |
-make_fcontext:
|
|
|
62e5e2 |
+#define ARG_OFFSET 0
|
|
|
62e5e2 |
+#define GR_OFFSET 16
|
|
|
62e5e2 |
+#define R14_OFFSET 88
|
|
|
62e5e2 |
+#define FP_OFFSET 96
|
|
|
62e5e2 |
+#define FPC_OFFSET 160
|
|
|
62e5e2 |
+#define PC_OFFSET 168
|
|
|
62e5e2 |
+#define CONTEXT_SIZE 176
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # make_fcontext takes in 3 arguments
|
|
|
62e5e2 |
- # arg1 --> The address where the context needs to be made
|
|
|
62e5e2 |
- # arg2 --> The size of the context
|
|
|
62e5e2 |
- # arg3 --> The address of the context function
|
|
|
62e5e2 |
+/*
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # According to the ELF ABI, the register R2 holds the first arg.
|
|
|
62e5e2 |
- # R2 also acts as the register which holds return value
|
|
|
62e5e2 |
- # Register R3 holds the second, R4 the third so on.
|
|
|
62e5e2 |
+fcontext_t make_fcontext( void * sp, std::size_t size, void (* fn)( transfer_t) );
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # Shift the address in R2 to a lower 8 byte boundary
|
|
|
62e5e2 |
+Create and return a context below SP to call FN.
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # This is done because according to the ELF ABI Doc, the stack needs
|
|
|
62e5e2 |
- # to be 8 byte aligned.
|
|
|
62e5e2 |
- # In order to do so, we need to make sure that the address is divisible
|
|
|
62e5e2 |
- # by 8. We can check this, by checking if the the last 3 bits of the
|
|
|
62e5e2 |
- # address is zero or not. If not AND it with `-8`.
|
|
|
62e5e2 |
+Incoming args
|
|
|
62e5e2 |
+r2 - The stack location where to create the context
|
|
|
62e5e2 |
+r3 - The size of the context
|
|
|
62e5e2 |
+r4 - The address of the context function
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # Here we AND the lower 16 bits of the memory address present in the
|
|
|
62e5e2 |
- # R2 with the bits 1111 1111 1111 1000
|
|
|
62e5e2 |
- nill %r2,0xfff0
|
|
|
62e5e2 |
+*/
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # Reserve space for context-data on context-stack.
|
|
|
62e5e2 |
- # This is done by shifting the SP/address by 112 bytes.
|
|
|
62e5e2 |
- aghi %r2,-L_CTX
|
|
|
62e5e2 |
+make_fcontext:
|
|
|
62e5e2 |
+ .machine "z10"
|
|
|
62e5e2 |
+ /* Align the stack to an 8 byte boundary. */
|
|
|
62e5e2 |
+ nill %r2,0xfff0
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # third arg of make_fcontext() == address of the context-function
|
|
|
62e5e2 |
- # Store the address as a PC to jump in, whenever we call the
|
|
|
62e5e2 |
- # make_fcontext.
|
|
|
62e5e2 |
- stg %r4,PC_OFFSET(%r2)
|
|
|
62e5e2 |
+ /* Allocate stack space for the context. */
|
|
|
62e5e2 |
+ aghi %r2,-CONTEXT_SIZE
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # Save the address of finish as return-address for context-function
|
|
|
62e5e2 |
- # This will be entered after context-function return
|
|
|
62e5e2 |
- # The address of finish will be saved in Link register, this register
|
|
|
62e5e2 |
- # specifies where we need to jump after the function executes
|
|
|
62e5e2 |
- # completely.
|
|
|
62e5e2 |
- larl %r1,finish
|
|
|
62e5e2 |
- stg %r1,LR_OFFSET(%r2)
|
|
|
62e5e2 |
+ /* Set the r2 save slot to zero. This indicates jump_fcontext
|
|
|
62e5e2 |
+ that this is a special context. */
|
|
|
62e5e2 |
+ mvghi GR_OFFSET(%r2),0
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # Return pointer to context data
|
|
|
62e5e2 |
- # R14 acts as the link register
|
|
|
62e5e2 |
- # R2 holds the address of the context stack. When we return from the
|
|
|
62e5e2 |
- # make_fcontext, R2 is passed back.
|
|
|
62e5e2 |
- br %r14
|
|
|
62e5e2 |
+ /* Save the floating point control register. */
|
|
|
62e5e2 |
+ stfpc FPC_OFFSET(%r2)
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- finish:
|
|
|
62e5e2 |
+ /* Store the address of the target function as new pc. */
|
|
|
62e5e2 |
+ stg %r4,PC_OFFSET(%r2)
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- # In finish tasks, you load the exit code and exit the make_fcontext
|
|
|
62e5e2 |
- # This is called when the context-function is entirely executed
|
|
|
62e5e2 |
+ /* Store a pointer to the finish routine as r14. If a function
|
|
|
62e5e2 |
+ called via context routines just returns that value will be
|
|
|
62e5e2 |
+ loaded and used as return address. Hence the program will
|
|
|
62e5e2 |
+ just exit. */
|
|
|
62e5e2 |
+ larl %r1,finish
|
|
|
62e5e2 |
+ stg %r1,R14_OFFSET(%r2)
|
|
|
62e5e2 |
|
|
|
62e5e2 |
- lghi %r2,0
|
|
|
62e5e2 |
- brasl %r14,_exit@PLT
|
|
|
62e5e2 |
+ /* Return as usual with the new context returned in r2. */
|
|
|
62e5e2 |
+ br %r14
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+finish:
|
|
|
62e5e2 |
+ /* In finish tasks, you load the exit code and exit the
|
|
|
62e5e2 |
+ make_fcontext This is called when the context-function is
|
|
|
62e5e2 |
+ entirely executed. */
|
|
|
62e5e2 |
+ lghi %r2,0
|
|
|
62e5e2 |
+ brasl %r14,_exit@PLT
|
|
|
62e5e2 |
|
|
|
62e5e2 |
.size make_fcontext,.-make_fcontext
|
|
|
62e5e2 |
-# Mark that we don't need executable stack.
|
|
|
62e5e2 |
.section .note.GNU-stack,"",%progbits
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
diff --git a/src/asm/ontop_s390x_sysv_elf_gas.S b/src/asm/ontop_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
index 4488654..709b3d6 100644
|
|
|
62e5e2 |
--- a/libs/context/src/asm/ontop_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
+++ b/libs/context/src/asm/ontop_s390x_sysv_elf_gas.S
|
|
|
62e5e2 |
@@ -1,112 +1,146 @@
|
|
|
62e5e2 |
/*******************************************************
|
|
|
62e5e2 |
-* *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 0 | 8 | 16 | 24 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R6 | R7 | R8 | R9 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 32 | 40 | 48 | 56 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R10 | R11 | R12 | R13 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 64 | 72 | 80 | 88 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | R14/LR | R15 | F1 | F3 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 24 | 25 | 26 | 27 | 28 | 29 | | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | 96 | 104 | 112 | 120 | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* | F5 | F7 | PC | | *
|
|
|
62e5e2 |
-* ------------------------------------------------- *
|
|
|
62e5e2 |
-* *****************************************************/
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
-.file "ontop_s390x_sysv_elf_gas.S"
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 0 | 8 | 16 | 24 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | t.fctx | t.data | r2 | r6 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 32 | 40 | 48 | 56 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | r7 | r8 | r9 | r10 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 64 | 72 | 80 | 88 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | r11 | r12 | r13 | r14 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 96 | 104 | 112 | 120 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | f8 | f9 | f10 | f11 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 128 | 136 | 144 | 152 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | f12 | f13 | f14 | f15 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | 160 | 168 | 176 | | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ * | fpc | pc | | | *
|
|
|
62e5e2 |
+ * ------------------------------------------------- *
|
|
|
62e5e2 |
+ *******************************************************/
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
.text
|
|
|
62e5e2 |
-.align 4 # According to the sample code in the ELF ABI docs
|
|
|
62e5e2 |
+.align 8
|
|
|
62e5e2 |
.global ontop_fcontext
|
|
|
62e5e2 |
.type ontop_fcontext, @function
|
|
|
62e5e2 |
|
|
|
62e5e2 |
-#define GR_OFFSET 0
|
|
|
62e5e2 |
-#define LR_OFFSET 64
|
|
|
62e5e2 |
-#define SP_OFFSET 72
|
|
|
62e5e2 |
-#define FP_OFFSET 80
|
|
|
62e5e2 |
-#define PC_OFFSET 112
|
|
|
62e5e2 |
-#define L_CTX 120
|
|
|
62e5e2 |
+#define ARG_OFFSET 0
|
|
|
62e5e2 |
+#define GR_OFFSET 16
|
|
|
62e5e2 |
+#define R14_OFFSET 88
|
|
|
62e5e2 |
+#define FP_OFFSET 96
|
|
|
62e5e2 |
+#define FPC_OFFSET 160
|
|
|
62e5e2 |
+#define PC_OFFSET 168
|
|
|
62e5e2 |
+#define CONTEXT_SIZE 176
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+/*
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+typedef void* fcontext_t;
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+struct transfer_t {
|
|
|
62e5e2 |
+ fcontext_t fctx;
|
|
|
62e5e2 |
+ void * data;
|
|
|
62e5e2 |
+};
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+transfer_t ontop_fcontext( fcontext_t const to,
|
|
|
62e5e2 |
+ void * vp,
|
|
|
62e5e2 |
+ transfer_t (* fn)( transfer_t) );
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+Incoming args
|
|
|
62e5e2 |
+r2 - Hidden argument to the location where the return transfer_t needs to be returned
|
|
|
62e5e2 |
+r3 - Target context
|
|
|
62e5e2 |
+r4 - Data pointer
|
|
|
62e5e2 |
+r5 - Function to be executed
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+This implementation assumes that ontop_fcontext will never be called with target contexts
|
|
|
62e5e2 |
+created via make_fcontext.
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+*/
|
|
|
62e5e2 |
|
|
|
62e5e2 |
ontop_fcontext:
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Reserved the space for stack to store the data of current context
|
|
|
62e5e2 |
- # before we jump to the new context.
|
|
|
62e5e2 |
- aghi %r15,-L_CTX
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # save the registers to the stack
|
|
|
62e5e2 |
- stmg %r6, %r15, GR_OFFSET(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # save the floating point registers
|
|
|
62e5e2 |
- std %f0,FP_OFFSET(%r15)
|
|
|
62e5e2 |
- std %f3,FP_OFFSET+8(%r15)
|
|
|
62e5e2 |
- std %f5,FP_OFFSET+16(%r15)
|
|
|
62e5e2 |
- std %f7,FP_OFFSET+24(%r15)
|
|
|
62e5e2 |
- # Save LR as PC
|
|
|
62e5e2 |
- stg %r14,PC_OFFSET(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Store the SP pointing to the old context-data into R0
|
|
|
62e5e2 |
- lgr %r0,%r15
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Get the SP pointing to the new context-data
|
|
|
62e5e2 |
- # Note: Since the return type of the jump_fcontext is struct whose
|
|
|
62e5e2 |
- # size is more than 8. The compiler automatically passes the
|
|
|
62e5e2 |
- # address of the transfer_t where the data needs to store into R2.
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Hence the first param passed to the jump_fcontext which represent
|
|
|
62e5e2 |
- # the fctx we want to switch to is present in R3
|
|
|
62e5e2 |
- # R2 --> Address of the return transfer_t struct
|
|
|
62e5e2 |
- # R3 --> Context we want to switch to
|
|
|
62e5e2 |
- # R4 --> Data
|
|
|
62e5e2 |
- lgr %r15,%r3
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Load the registers with the data present in context-data of the
|
|
|
62e5e2 |
- # context we are going to switch to
|
|
|
62e5e2 |
- lmg %r6,%r15,GR_OFFSET(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Restore Floating point registers
|
|
|
62e5e2 |
- ld %f1,FP_OFFSET(%r15)
|
|
|
62e5e2 |
- ld %f3,FP_OFFSET+8(%r15)
|
|
|
62e5e2 |
- ld %f5,FP_OFFSET+16(%r15)
|
|
|
62e5e2 |
- ld %f7,FP_OFFSET+24(%r15)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Skip PC
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Adjust the stack
|
|
|
62e5e2 |
- aghi %r15,L_CTX
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # R2 --> Address where the return transfer_t is stored
|
|
|
62e5e2 |
- # R0 --> FCTX
|
|
|
62e5e2 |
- # R4 --> DATA
|
|
|
62e5e2 |
- # R5 --> Context function
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Store the elements to return transfer_t
|
|
|
62e5e2 |
- stg %r15, 0(%r2)
|
|
|
62e5e2 |
- stg %r4, 8(%r2)
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- # Note: The address in R2 points to the place where the return
|
|
|
62e5e2 |
- # transfer_t is stored. Since context_function take transfer_t
|
|
|
62e5e2 |
- # as first parameter. And R2 is the register which holds the
|
|
|
62e5e2 |
- # first parameter value.
|
|
|
62e5e2 |
-
|
|
|
62e5e2 |
- #jump to context function
|
|
|
62e5e2 |
- br %r5
|
|
|
62e5e2 |
+ /* Reserve stack space to store the current context. */
|
|
|
62e5e2 |
+ aghi %r15,-CONTEXT_SIZE
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Save the argument register holding the location of the return value. */
|
|
|
62e5e2 |
+ stg %r2,GR_OFFSET(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Save the call-saved general purpose registers. */
|
|
|
62e5e2 |
+ stmg %r6,%r14,GR_OFFSET+8(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Save call-saved floating point registers. */
|
|
|
62e5e2 |
+ std %f8,FP_OFFSET(%r15)
|
|
|
62e5e2 |
+ std %f9,FP_OFFSET+8(%r15)
|
|
|
62e5e2 |
+ std %f10,FP_OFFSET+16(%r15)
|
|
|
62e5e2 |
+ std %f11,FP_OFFSET+24(%r15)
|
|
|
62e5e2 |
+ std %f12,FP_OFFSET+32(%r15)
|
|
|
62e5e2 |
+ std %f13,FP_OFFSET+40(%r15)
|
|
|
62e5e2 |
+ std %f14,FP_OFFSET+48(%r15)
|
|
|
62e5e2 |
+ std %f15,FP_OFFSET+56(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Save the return address as current pc. */
|
|
|
62e5e2 |
+ stg %r14,PC_OFFSET(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Save the floating point control register. */
|
|
|
62e5e2 |
+ stfpc FPC_OFFSET(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Backup the stack pointer pointing to the old context-data into r1. */
|
|
|
62e5e2 |
+ lgr %r1,%r15
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Load the new context pointer as stack pointer. */
|
|
|
62e5e2 |
+ lgr %r15,%r3
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Restore the call-saved GPRs from the new context. */
|
|
|
62e5e2 |
+ lmg %r6,%r14,GR_OFFSET+8(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Restore call-saved floating point registers. */
|
|
|
62e5e2 |
+ ld %f8,FP_OFFSET(%r15)
|
|
|
62e5e2 |
+ ld %f9,FP_OFFSET+8(%r15)
|
|
|
62e5e2 |
+ ld %f10,FP_OFFSET+16(%r15)
|
|
|
62e5e2 |
+ ld %f11,FP_OFFSET+24(%r15)
|
|
|
62e5e2 |
+ ld %f12,FP_OFFSET+32(%r15)
|
|
|
62e5e2 |
+ ld %f13,FP_OFFSET+40(%r15)
|
|
|
62e5e2 |
+ ld %f14,FP_OFFSET+48(%r15)
|
|
|
62e5e2 |
+ ld %f15,FP_OFFSET+56(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Load the floating point control register. */
|
|
|
62e5e2 |
+ lfpc FPC_OFFSET(%r15)
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Store the transfer_t values located in the saved context. */
|
|
|
62e5e2 |
+ stg %r1,0(%r1) /* transfer_t.fctx = old context */
|
|
|
62e5e2 |
+ stg %r4,8(%r1) /* transfer_t.data = data */
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Set up the arguments for the target function. */
|
|
|
62e5e2 |
+ lg %r2,GR_OFFSET(%r15)
|
|
|
62e5e2 |
+ lgr %r3,%r1
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ /* Deallocate the context. */
|
|
|
62e5e2 |
+ aghi %r15,CONTEXT_SIZE
|
|
|
62e5e2 |
+
|
|
|
62e5e2 |
+ br %r5
|
|
|
62e5e2 |
|
|
|
62e5e2 |
.size ontop_fcontext,.-ontop_fcontext
|
|
|
62e5e2 |
-# Mark that we don't need executable stack.
|
|
|
62e5e2 |
.section .note.GNU-stack,"",%progbits
|
|
|
62e5e2 |
--
|
|
|
62e5e2 |
2.18.1
|
|
|
62e5e2 |
|