fix build for ppc, update context asm

master
Daniel Kolesa 2018-12-09 01:36:04 +01:00
parent 8a7a4d6914
commit 5728c30da1
47 changed files with 749 additions and 250 deletions

View File

@ -38,10 +38,12 @@
* *
*******************************************************/
.file "jump_arm_aapcs_elf_gas.S"
.text
.globl ostd_jump_fcontext
.align 2
.type ostd_jump_fcontext,%function
.syntax unified
ostd_jump_fcontext:
@ save LR as PC
push {lr}

View File

@ -38,16 +38,18 @@
* *
*******************************************************/
.file "make_arm_aapcs_elf_gas.S"
.text
.globl ostd_make_fcontext
.align 2
.type ostd_make_fcontext,%function
.syntax unified
ostd_make_fcontext:
@ shift address in A1 to lower 16 byte boundary
bic a1, a1, #15
@ reserve space for context-data on context-stack
sub a1, a1, #128
sub a1, a1, #124
@ third arg of ostd_make_fcontext() == address of context-function
str a3, [a1, #104]

View File

@ -46,7 +46,7 @@ _ostd_make_fcontext:
bic a1, a1, #15
@ reserve space for context-data on context-stack
sub a1, a1, #128
sub a1, a1, #124
@ third arg of ostd_make_fcontext() == address of context-function
str a3, [a1, #108]

View File

@ -38,10 +38,12 @@
* *
*******************************************************/
.file "ontop_arm_aapcs_elf_gas.S"
.text
.globl ostd_ontop_fcontext
.align 2
.type ostd_ontop_fcontext,%function
.syntax unified
ostd_ontop_fcontext:
@ save LR as PC
push {lr}

View File

@ -51,6 +51,7 @@
* *
*******************************************************/
.file "jump_arm64_aapcs_elf_gas.S"
.text
.align 2
.global ostd_jump_fcontext

View File

@ -51,6 +51,7 @@
* *
*******************************************************/
.file "make_arm64_aapcs_elf_gas.S"
.text
.align 2
.global ostd_make_fcontext

View File

@ -51,6 +51,7 @@
* *
*******************************************************/
.file "ontop_arm64_aapcs_elf_gas.S"
.text
.align 2
.global ostd_ontop_fcontext

View File

@ -32,10 +32,12 @@ _ostd_jump_fcontext:
/* prepare stack */
leal -0x2c(%esp), %esp
#if !defined(OSTD_USE_TSX)
/* save MMX control- and status-word */
stmxcsr (%esp)
/* save x87 control-word */
fnstcw 0x4(%esp)
#endif
/* load NT_TIB */
movl %fs:(0x18), %edx
@ -69,10 +71,12 @@ _ostd_jump_fcontext:
/* restore ESP (pointing to context-data) from ECX */
movl %ecx, %esp
#if !defined(OSTD_USE_TSX)
/* restore MMX control- and status-word */
ldmxcsr (%esp)
/* restore x87 control-word */
fldcw 0x4(%esp)
#endif
/* restore NT_TIB into EDX */
movl %fs:(0x18), %edx

View File

@ -28,10 +28,12 @@ ostd_jump_fcontext PROC OSTD_CONTEXT_EXPORT
; prepare stack
lea esp, [esp-02ch]
IFNDEF OSTD_USE_TSX
; save MMX control- and status-word
stmxcsr [esp]
; save x87 control-word
fnstcw [esp+04h]
ENDIF
assume fs:nothing
; load NT_TIB into ECX
@ -67,10 +69,12 @@ ostd_jump_fcontext PROC OSTD_CONTEXT_EXPORT
; restore ESP (pointing to context-data) from ECX
mov esp, ecx
IFNDEF OSTD_USE_TSX
; restore MMX control- and status-word
ldmxcsr [esp]
; restore x87 control-word
fldcw [esp+04h]
ENDIF
assume fs:nothing
; load NT_TIB into EDX

View File

@ -24,6 +24,7 @@
* *
****************************************************************************************/
.file "jump_i386_sysv_elf_gas.S"
.text
.globl ostd_jump_fcontext
.align 2
@ -31,8 +32,10 @@
ostd_jump_fcontext:
leal -0x18(%esp), %esp /* prepare stack */
#if !defined(OSTD_USE_TSX)
stmxcsr (%esp) /* save MMX control- and status-word */
fnstcw 0x4(%esp) /* save x87 control-word */
#endif
movl %edi, 0x8(%esp) /* save EDI */
movl %esi, 0xc(%esp) /* save ESI */
@ -60,8 +63,10 @@ ostd_jump_fcontext:
movl 0x18(%esp), %ecx /* restore EIP */
#if !defined(OSTD_USE_TSX)
ldmxcsr (%esp) /* restore MMX control- and status-word */
fldcw 0x4(%esp) /* restore x87 control-word */
#endif
movl 0x8(%esp), %edi /* restore EDI */
movl 0xc(%esp), %esi /* restore ESI */

View File

@ -12,14 +12,14 @@
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | to | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | | *
* | 0x20 | | *
* ---------------------------------------------------------------------------------- *
* | to | data | | *
* | data | | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
@ -30,8 +30,10 @@
_ostd_jump_fcontext:
leal -0x18(%esp), %esp /* prepare stack */
#if !defined(OSTD_USE_TSX)
stmxcsr (%esp) /* save MMX control- and status-word */
fnstcw 0x4(%esp) /* save x87 control-word */
#endif
movl %edi, 0x8(%esp) /* save EDI */
movl %esi, 0xc(%esp) /* save ESI */
@ -42,32 +44,32 @@ _ostd_jump_fcontext:
movl %esp, %ecx
/* first arg of ostd_jump_fcontext() == fcontext to jump to */
movl 0x20(%esp), %eax
movl 0x1c(%esp), %eax
/* second arg of ostd_jump_fcontext() == data to be transferred */
movl 0x24(%esp), %edx
movl 0x20(%esp), %edx
/* restore ESP (pointing to context-data) from EAX */
movl %eax, %esp
/* address of returned transport_t */
movl 0x1c(%esp), %eax
/* return parent fcontext_t */
movl %ecx, (%eax)
/* return data */
movl %ecx, %eax
/* returned data is stored in EDX */
movl %edx, 0x4(%eax)
movl 0x18(%esp), %ecx /* restore EIP */
#if !defined(OSTD_USE_TSX)
ldmxcsr (%esp) /* restore MMX control- and status-word */
fldcw 0x4(%esp) /* restore x87 control-word */
#endif
movl 0x8(%esp), %edi /* restore EDI */
movl 0xc(%esp), %esi /* restore ESI */
movl 0x10(%esp), %ebx /* restore EBX */
movl 0x14(%esp), %ebp /* restore EBP */
leal 0x20(%esp), %esp /* prepare stack */
leal 0x1c(%esp), %esp /* prepare stack */
/* jump to context */
jmp *%ecx

View File

@ -24,6 +24,7 @@
* *
****************************************************************************************/
.file "make_i386_sysv_elf_gas.S"
.text
.globl ostd_make_fcontext
.align 2

View File

@ -12,14 +12,14 @@
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | to | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | | *
* | 0x20 | | *
* ---------------------------------------------------------------------------------- *
* | to | data | | *
* | data | | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
@ -39,7 +39,7 @@ _ostd_make_fcontext:
andl $-16, %eax
/* reserve space for context-data on context-stack */
leal -0x28(%eax), %eax
leal -0x2c(%eax), %eax
/* third arg of ostd_make_fcontext() == address of context-function */
/* stored in EBX */
@ -51,11 +51,6 @@ _ostd_make_fcontext:
/* save x87 control-word */
fnstcw 0x4(%eax)
/* return transport_t */
/* FCTX == EDI, DATA == ESI */
leal 0x8(%eax), %ecx
movl %ecx, 0x1c(%eax)
/* compute abs address of label trampoline */
call 1f
/* address of trampoline 1 */
@ -80,8 +75,8 @@ _ostd_make_fcontext:
trampoline:
/* move transport_t for entering context-function */
movl %edi, (%esp)
movl %esi, 0x4(%esp)
movl %eax, (%esp)
movl %edx, 0x4(%esp)
pushl %ebp
/* jump to context-function */
jmp *%ebx

View File

@ -32,10 +32,12 @@ _ostd_ontop_fcontext:
/* prepare stack */
leal -0x2c(%esp), %esp
#if !defined(OSTD_USE_TSX)
/* save MMX control- and status-word */
stmxcsr (%esp)
/* save x87 control-word */
fnstcw 0x4(%esp)
#endif
/* load NT_TIB */
movl %fs:(0x18), %edx
@ -81,10 +83,12 @@ _ostd_ontop_fcontext:
/* restore ESP (pointing to context-data) from EDX */
movl %eax, %esp
#if !defined(OSTD_USE_TSX)
/* restore MMX control- and status-word */
ldmxcsr (%esp)
/* restore x87 control-word */
fldcw 0x4(%esp)
#endif
/* restore NT_TIB into EDX */
movl %fs:(0x18), %edx

View File

@ -28,10 +28,12 @@ ostd_ontop_fcontext PROC OSTD_CONTEXT_EXPORT
; prepare stack
lea esp, [esp-02ch]
IFNDEF OSTD_USE_TSX
; save MMX control- and status-word
stmxcsr [esp]
; save x87 control-word
fnstcw [esp+04h]
ENDIF
assume fs:nothing
; load NT_TIB into ECX
@ -79,10 +81,12 @@ ostd_ontop_fcontext PROC OSTD_CONTEXT_EXPORT
; restore ESP (pointing to context-data) from EAX
mov esp, eax
IFNDEF OSTD_USE_TSX
; restore MMX control- and status-word
ldmxcsr [esp]
; restore x87 control-word
fldcw [esp+04h]
ENDIF
assume fs:nothing
; load NT_TIB into EDX

View File

@ -24,6 +24,7 @@
* *
****************************************************************************************/
.file "ontop_i386_sysv_elf_gas.S"
.text
.globl ostd_ontop_fcontext
.align 2
@ -31,8 +32,10 @@
ostd_ontop_fcontext:
leal -0x18(%esp), %esp /* prepare stack */
#if !defined(OSTD_USE_TSX)
stmxcsr (%esp) /* save MMX control- and status-word */
fnstcw 0x4(%esp) /* save x87 control-word */
#endif
movl %edi, 0x8(%esp) /* save EDI */
movl %esi, 0xc(%esp) /* save ESI */
@ -67,8 +70,10 @@ ostd_ontop_fcontext:
/* return data */
movl %edx, 0x4(%eax)
#if !defined(OSTD_USE_TSX)
ldmxcsr (%esp) /* restore MMX control- and status-word */
fldcw 0x4(%esp) /* restore x87 control-word */
#endif
movl 0x8(%esp), %edi /* restore EDI */
movl 0xc(%esp), %esi /* restore ESI */

View File

@ -12,14 +12,14 @@
* ---------------------------------------------------------------------------------- *
* | 0x0 | 0x4 | 0x8 | 0xc | 0x10 | 0x14 | 0x18 | 0x1c | *
* ---------------------------------------------------------------------------------- *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | hidden | *
* | fc_mxcsr|fc_x87_cw| EDI | ESI | EBX | EBP | EIP | to | *
* ---------------------------------------------------------------------------------- *
* ---------------------------------------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ---------------------------------------------------------------------------------- *
* | 0x20 | 0x24 | | *
* | 0x20 | | *
* ---------------------------------------------------------------------------------- *
* | to | data | | *
* | data | | *
* ---------------------------------------------------------------------------------- *
* *
****************************************************************************************/
@ -30,8 +30,10 @@
_ostd_ontop_fcontext:
leal -0x18(%esp), %esp /* prepare stack */
#if !defined(OSTD_USE_TSX)
stmxcsr (%esp) /* save MMX control- and status-word */
fnstcw 0x4(%esp) /* save x87 control-word */
#endif
movl %edi, 0x8(%esp) /* save EDI */
movl %esi, 0xc(%esp) /* save ESI */
@ -42,32 +44,31 @@ _ostd_ontop_fcontext:
movl %esp, %ecx
/* first arg of ostd_ontop_fcontext() == fcontext to jump to */
movl 0x20(%esp), %eax
movl 0x1c(%esp), %eax
/* pass parent fcontext_t */
movl %ecx, 0x20(%eax)
movl %ecx, 0x1c(%eax)
/* second arg of ostd_ontop_fcontext() == data to be transferred */
movl 0x24(%esp), %ecx
movl 0x20(%esp), %ecx
/* pass data */
movl %ecx, 0x24(%eax)
movl %ecx, 0x20(%eax)
/* third arg of ostd_ontop_fcontext() == ontop-function */
movl 0x28(%esp), %ecx
movl 0x24(%esp), %ecx
/* restore ESP (pointing to context-data) from EAX */
movl %eax, %esp
/* address of returned transport_t */
movl 0x1c(%esp), %eax
/* return parent fcontext_t */
movl %ecx, (%eax)
/* return data */
movl %edx, 0x4(%eax)
movl %ecx, %eax
/* returned data is stored in EDX */
#if !defined(OSTD_USE_TSX)
ldmxcsr (%esp) /* restore MMX control- and status-word */
fldcw 0x4(%esp) /* restore x87 control-word */
#endif
movl 0x8(%esp), %edi /* restore EDI */
movl 0xc(%esp), %esi /* restore ESI */

View File

@ -21,15 +21,7 @@
# else
# include "x86_64/jump_x86_64_sysv_elf_gas.S"
# endif
#elif defined(__ppc__)
# if defined(__APPLE__)
# include "ppc32/jump_ppc32_sysv_macho_gas.S"
# elif defined(_AIX)
# include "ppc32/jump_ppc32_sysv_xcoff_gas.S"
# else
# include "ppc32/jump_ppc32_sysv_elf_gas.S"
# endif
#elif defined(__ppc64__)
#elif defined(__ppc64__) || defined(__PPC64__)
# if defined(__APPLE__)
# include "ppc64/jump_ppc64_sysv_macho_gas.S"
# elif defined(_AIX)
@ -37,6 +29,14 @@
# else
# include "ppc64/jump_ppc64_sysv_elf_gas.S"
# endif
#elif defined(__ppc__) || defined(__PPC__)
# if defined(__APPLE__)
# include "ppc32/jump_ppc32_sysv_macho_gas.S"
# elif defined(_AIX)
# include "ppc32/jump_ppc32_sysv_xcoff_gas.S"
# else
# include "ppc32/jump_ppc32_sysv_elf_gas.S"
# endif
#elif defined(__aarch64__)
# if defined(__APPLE__)
# include "arm64/jump_arm64_aapcs_macho_gas.S"

View File

@ -21,15 +21,7 @@
# else
# include "x86_64/make_x86_64_sysv_elf_gas.S"
# endif
#elif defined(__ppc__)
# if defined(__APPLE__)
# include "ppc32/make_ppc32_sysv_macho_gas.S"
# elif defined(_AIX)
# include "ppc32/make_ppc32_sysv_xcoff_gas.S"
# else
# include "ppc32/make_ppc32_sysv_elf_gas.S"
# endif
#elif defined(__ppc64__)
#elif defined(__ppc64__) || defined(__PPC64__)
# if defined(__APPLE__)
# include "ppc64/make_ppc64_sysv_macho_gas.S"
# elif defined(_AIX)
@ -37,6 +29,14 @@
# else
# include "ppc64/make_ppc64_sysv_elf_gas.S"
# endif
#elif defined(__ppc__) || defined(__PPC__)
# if defined(__APPLE__)
# include "ppc32/make_ppc32_sysv_macho_gas.S"
# elif defined(_AIX)
# include "ppc32/make_ppc32_sysv_xcoff_gas.S"
# else
# include "ppc32/make_ppc32_sysv_elf_gas.S"
# endif
#elif defined(__aarch64__)
# if defined(__APPLE__)
# include "arm64/make_arm64_aapcs_macho_gas.S"

View File

@ -33,11 +33,12 @@
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | GP | FCTX| DATA| | | | | | *
* | ABI ARGS | GP | FCTX| DATA| | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "jump_mips32_o32_elf_gas.S"
.text
.globl ostd_jump_fcontext
.align 2
@ -45,7 +46,7 @@
.ent ostd_jump_fcontext
ostd_jump_fcontext:
# reserve space on stack
addiu $sp, $sp, -112
addiu $sp, $sp, -96
sw $s0, 48($sp) # save S0
sw $s1, 52($sp) # save S1
@ -93,18 +94,18 @@ ostd_jump_fcontext:
lw $s6, 72($sp) # restore S6
lw $s7, 76($sp) # restore S7
lw $fp, 80($sp) # restore FP
lw $t0, 84($sp) # restore hidden, address of returned transfer_t
lw $v0, 84($sp) # restore hidden, address of returned transfer_t
lw $ra, 88($sp) # restore RA
# load PC
lw $t9, 92($sp)
# adjust stack
addiu $sp, $sp, 112
addiu $sp, $sp, 96
# return transfer_t from jump
sw $a0, ($t0) # fctx of transfer_t
sw $a2, 4($t0) # data of transfer_t
sw $a0, ($v0) # fctx of transfer_t
sw $a2, 4($v0) # data of transfer_t
# pass transfer_t as first arg in context function
# A0 == fctx, A1 == data
move $a1, $a2

View File

@ -5,24 +5,6 @@
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 4 | 8 | 12 | 16 | 20 | 24 | 28 | *
* ------------------------------------------------- *
* | S0 | S1 | S2 | S3 | S4 | S5 | S6 | S7 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 36 | 40 | 44 | 48 | 52 | 56 | 60 | *
* ------------------------------------------------- *
* | FP |hiddn| RA | PC | GP | FCTX| DATA| | *
* ------------------------------------------------- *
* *
* *****************************************************/
/*******************************************************
* *
* ------------------------------------------------- *
@ -51,11 +33,12 @@
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | GP | FCTX| DATA| | | | | | *
* | ABI ARGS | GP | FCTX| DATA| | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "make_mips32_o32_elf_gas.S"
.text
.globl ostd_make_fcontext
.align 2
@ -67,25 +50,26 @@ ostd_make_fcontext:
.cpload $t9
.set reorder
#endif
# first arg of ostd_make_fcontext() == top address of context-stack
move $v0, $a0
# shift address in A0 to lower 16 byte boundary
move $v1, $v0
li $v0, -16 # 0xfffffffffffffff0
and $v0, $v1, $v0
li $v1, -16 # 0xfffffffffffffff0
and $v0, $v1, $a0
# reserve space for context-data on context-stack
# including 48 byte of shadow space (sp % 16 == 0)
addiu $v0, $v0, -112
# includes an extra 32 bytes for:
# - 16-byte incoming argument area required by mips ABI used when
# jump_context calls the initial function
# - 4 bytes to save our GP register used in finish
# - 8 bytes to as space for transfer_t returned to finish
# - 4 bytes for alignment
addiu $v0, $v0, -128
# third arg of ostd_make_fcontext() == address of context-function
sw $a2, 92($v0)
# save global pointer in context-data
sw $gp, 96($v0)
sw $gp, 112($v0)
# compute address of returned transfer_t
addiu $t0, $v0, 52
addiu $t0, $v0, 116
sw $t0, 84($v0)
# compute abs address of label finish
@ -97,20 +81,15 @@ ostd_make_fcontext:
jr $ra # return pointer to context-data
finish:
lw $gp, 0($sp)
# allocate stack space (contains shadow space for subroutines)
addiu $sp, $sp, -32
# save return address
sw $ra, 28($sp)
# reload our gp register (needed for la)
lw $gp, 16($sp)
# restore GP (global pointer)
# move $gp, $s1
# exit code is zero
move $a0, $zero
# address of exit
lw $t9, %call16(_exit)($gp)
# exit application
jalr $t9
# call _exit(0)
# the previous function should have left the 16 bytes incoming argument
# area on the stack which we reuse for calling _exit
la $t9, _exit
move $a0, $zero
jr $t9
.end ostd_make_fcontext
.size ostd_make_fcontext, .-ostd_make_fcontext

View File

@ -33,11 +33,12 @@
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | GP | FCTX| DATA| | | | | | *
* | ABI ARGS | GP | FCTX| DATA| | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "ontop_mips32_o32_elf_gas.S"
.text
.globl ostd_ontop_fcontext
.align 2
@ -45,7 +46,7 @@
.ent ostd_ontop_fcontext
ostd_ontop_fcontext:
# reserve space on stack
addiu $sp, $sp, -112
addiu $sp, $sp, -96
sw $s0, 48($sp) # save S0
sw $s1, 52($sp) # save S1
@ -93,25 +94,25 @@ ostd_ontop_fcontext:
lw $s6, 72($sp) # restore S6
lw $s7, 76($sp) # restore S7
lw $fp, 80($sp) # restore FP
lw $t0, 84($sp) # restore hidden, address of returned transfer_t
lw $v0, 84($sp) # restore hidden, address of returned transfer_t
lw $ra, 88($sp) # restore RA
# load PC
lw $t9, 44($sp)
move $t9, $a3
# adjust stack
addiu $sp, $sp, 112
addiu $sp, $sp, 96
# return transfer_t from jump
sw $a0, ($t0) # fctx of transfer_t
sw $a2, 4($t0) # data of transfer_t
sw $a0, ($v0) # fctx of transfer_t
sw $a2, 4($v0) # data of transfer_t
# pass transfer_t as first arg in context function
# A0 == hidden, A1 == fctx, A2 == data
move $a1, $a0
move $a0, $t0
move $a0, $v0
# jump to context
jr $a3
jr $t9
.end ostd_ontop_fcontext
.size ostd_ontop_fcontext, .-ostd_ontop_fcontext

View File

@ -0,0 +1,121 @@
/*
Copyright Jiaxun Yang 2018.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 8 | 16 | 24 | *
* ------------------------------------------------- *
* | F24 | F25 | F26 | F27 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 40 | 48 | 56 | *
* ------------------------------------------------- *
* | F28 | F29 | F30 | F31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 72 | 80 | 88 | *
* ------------------------------------------------- *
* | S0 | S1 | S2 | S3 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | S4 | S5 | S6 | S7 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | FP | GP | RA | PC | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "jump_mips64_n64_elf_gas.S"
.text
.globl ostd_jump_fcontext
.align 2
.type ostd_jump_fcontext,@function
.ent ostd_jump_fcontext
ostd_jump_fcontext:
# reserve space on stack
daddiu $sp, $sp, -160
sd $s0, 64($sp) # save S0
sd $s1, 72($sp) # save S1
sd $s2, 80($sp) # save S2
sd $s3, 88($sp) # save S3
sd $s4, 96($sp) # save S4
sd $s5, 104($sp) # save S5
sd $s6, 112($sp) # save S6
sd $s7, 120($sp) # save S7
sd $fp, 128($sp) # save FP
sd $ra, 144($sp) # save RA
sd $ra, 152($sp) # save RA as PC
s.d $f24, 0($sp) # save F24
s.d $f25, 8($sp) # save F25
s.d $f26, 16($sp) # save F26
s.d $f27, 24($sp) # save F27
s.d $f28, 32($sp) # save F28
s.d $f29, 40($sp) # save F29
s.d $f30, 48($sp) # save F30
s.d $f31, 56($sp) # save F31
# store SP (pointing to old context-data) in v0 as return
move $v0, $sp
# get SP (pointing to new context-data) from a0 param
move $sp, $a0
l.d $f24, 0($sp) # restore F24
l.d $f25, 8($sp) # restore F25
l.d $f26, 16($sp) # restore F26
l.d $f27, 24($sp) # restore F27
l.d $f28, 32($sp) # restore F28
l.d $f29, 40($sp) # restore F29
l.d $f30, 48($sp) # restore F30
l.d $f31, 56($sp) # restore F31
ld $s0, 64($sp) # restore S0
ld $s1, 72($sp) # restore S1
ld $s2, 80($sp) # restore S2
ld $s3, 88($sp) # restore S3
ld $s4, 96($sp) # restore S4
ld $s5, 104($sp) # restore S5
ld $s6, 112($sp) # restore S6
ld $s7, 120($sp) # restore S7
ld $fp, 128($sp) # restore FP
ld $ra, 144($sp) # restore RAa
# load PC
ld $t9, 152($sp)
# adjust stack
daddiu $sp, $sp, 160
move $a0, $v0 # move old sp from v0 to a0 as param
move $v1, $a1 # move *data from a1 to v1 as return
# jump to context
jr $t9
.end ostd_jump_fcontext
.size ostd_jump_fcontext, .-ostd_jump_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits

View File

@ -0,0 +1,96 @@
/*
Copyright Jiaxun Yang 2018.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 8 | 16 | 24 | *
* ------------------------------------------------- *
* | F24 | F25 | F26 | F27 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 40 | 48 | 56 | *
* ------------------------------------------------- *
* | F28 | F29 | F30 | F31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 72 | 80 | 88 | *
* ------------------------------------------------- *
* | S0 | S1 | S2 | S3 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | S4 | S5 | S6 | S7 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | FP | GP | RA | PC | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "make_mips64_n64_elf_gas.S"
.text
.globl ostd_make_fcontext
.align 2
.type ostd_make_fcontext,@function
.ent ostd_make_fcontext
ostd_make_fcontext:
#ifdef __PIC__
.set noreorder
.cpload $t9
.set reorder
#endif
# shift address in A0 to lower 16 byte boundary
li $v1, 0xfffffffffffffff0
and $v0, $v1, $a0
# reserve space for context-data on context-stack
daddiu $v0, $v0, -160
# third arg of ostd_make_fcontext() == address of context-function
sd $a2, 152($v0)
# save global pointer in context-data
sd $gp, 136($v0)
# psudo instruction compute abs address of label finish based on GP
dla $t9, finish
# save address of finish as return-address for context-function
# will be entered after context-function returns
sd $t9, 144($v0)
jr $ra # return pointer to context-data
finish:
# reload our gp register (needed for la)
daddiu $t0, $sp, -160
ld $gp, 136($t0)
# call _exit(0)
# the previous function should have left the 16 bytes incoming argument
# area on the stack which we reuse for calling _exit
dla $t9, _exit
move $a0, $zero
jr $t9
.end ostd_make_fcontext
.size ostd_make_fcontext, .-ostd_make_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits

View File

@ -0,0 +1,120 @@
/*
Copyright Jiaxun Yang 2018.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE
*/
/*******************************************************
* *
* ------------------------------------------------- *
* | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | *
* ------------------------------------------------- *
* | 0 | 8 | 16 | 24 | *
* ------------------------------------------------- *
* | F24 | F25 | F26 | F27 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | *
* ------------------------------------------------- *
* | 32 | 40 | 48 | 56 | *
* ------------------------------------------------- *
* | F28 | F29 | F30 | F31 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | *
* ------------------------------------------------- *
* | 64 | 72 | 80 | 88 | *
* ------------------------------------------------- *
* | S0 | S1 | S2 | S3 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | *
* ------------------------------------------------- *
* | 96 | 100 | 104 | 108 | 112 | 116 | 120 | 124 | *
* ------------------------------------------------- *
* | S4 | S5 | S6 | S7 | *
* ------------------------------------------------- *
* ------------------------------------------------- *
* | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | *
* ------------------------------------------------- *
* | 128 | 132 | 136 | 140 | 144 | 148 | 152 | 156 | *
* ------------------------------------------------- *
* | FP | GP | RA | PC | *
* ------------------------------------------------- *
* *
* *****************************************************/
.file "ontop_mips64_n64_elf_gas.S"
.text
.globl ostd_ontop_fcontext
.align 2
.type ostd_ontop_fcontext,@function
.ent ostd_ontop_fcontext
ostd_ontop_fcontext:
# reserve space on stack
daddiu $sp, $sp, -160
sd $s0, 64($sp) # save S0
sd $s1, 72($sp) # save S1
sd $s2, 80($sp) # save S2
sd $s3, 88($sp) # save S3
sd $s4, 96($sp) # save S4
sd $s5, 104($sp) # save S5
sd $s6, 112($sp) # save S6
sd $s7, 120($sp) # save S7
sd $fp, 128($sp) # save FP
sd $ra, 144($sp) # save RA
sd $ra, 152($sp) # save RA as PC
s.d $f24, 0($sp) # save F24
s.d $f25, 8($sp) # save F25
s.d $f26, 16($sp) # save F26
s.d $f27, 24($sp) # save F27
s.d $f28, 32($sp) # save F28
s.d $f29, 40($sp) # save F29
s.d $f30, 48($sp) # save F30
s.d $f31, 56($sp) # save F31
# store SP (pointing to context-data) in t0
move $t0, $sp
# restore SP (pointing to context-data) from a0
move $sp, $a0
l.d $f24, 0($sp) # restore F24
l.d $f25, 8($sp) # restore F25
l.d $f26, 16($sp) # restore F26
l.d $f27, 24($sp) # restore F27
l.d $f28, 32($sp) # restore F28
l.d $f29, 40($sp) # restore F29
l.d $f30, 48($sp) # restore F30
l.d $f31, 56($sp) # restore F31
ld $s0, 64($sp) # restore S0
ld $s1, 72($sp) # restore S1
ld $s2, 80($sp) # restore S2
ld $s3, 88($sp) # restore S3
ld $s4, 96($sp) # restore S4
ld $s5, 104($sp) # restore S5
ld $s6, 112($sp) # restore S6
ld $s7, 120($sp) # restore S7
ld $fp, 128($sp) # restore FP
ld $ra, 144($sp) # restore RA
# load PC
move $t9, $a2
# adjust stack
daddiu $sp, $sp, 160
move $a0, $t0 # move param from t0 to a0 as param
# jump to context
jr $t9
.end ostd_ontop_fcontext
.size ostd_ontop_fcontext, .-ostd_ontop_fcontext
/* Mark that we don't need executable stack. */
.section .note.GNU-stack,"",%progbits

View File

@ -21,15 +21,7 @@
# else
# include "x86_64/ontop_x86_64_sysv_elf_gas.S"
# endif
#elif defined(__ppc__)
# if defined(__APPLE__)
# include "ppc32/ontop_ppc32_sysv_macho_gas.S"
# elif defined(_AIX)
# include "ppc32/ontop_ppc32_sysv_xcoff_gas.S"
# else
# include "ppc32/ontop_ppc32_sysv_elf_gas.S"
# endif
#elif defined(__ppc64__)
#elif defined(__ppc64__) || defined(__PPC64__)
# if defined(__APPLE__)
# include "ppc64/ontop_ppc64_sysv_macho_gas.S"
# elif defined(_AIX)
@ -37,6 +29,14 @@
# else
# include "ppc64/ontop_ppc64_sysv_elf_gas.S"
# endif
#elif defined(__ppc__) || defined(__PPC__)
# if defined(__APPLE__)
# include "ppc32/ontop_ppc32_sysv_macho_gas.S"
# elif defined(_AIX)
# include "ppc32/ontop_ppc32_sysv_xcoff_gas.S"
# else
# include "ppc32/ontop_ppc32_sysv_elf_gas.S"
# endif
#elif defined(__aarch64__)
# if defined(__APPLE__)
# include "arm64/ontop_arm64_aapcs_macho_gas.S"

View File

@ -73,6 +73,7 @@
* *
*******************************************************/
.file "jump_ppc32_sysv_elf_gas.S"
.text
.globl ostd_jump_fcontext
.align 2

View File

@ -73,6 +73,7 @@
* *
*******************************************************/
.file "make_ppc32_sysv_elf_gas.S"
.text
.globl ostd_make_fcontext
.align 2

View File

@ -73,6 +73,7 @@
* *
*******************************************************/
.file "ontop_ppc32_sysv_elf_gas.S"
.text
.globl ostd_ontop_fcontext
.align 2

View File

@ -66,6 +66,7 @@
* *
*******************************************************/
.file "jump_ppc64_sysv_elf_gas.S"
.globl ostd_jump_fcontext
#if _CALL_ELF == 2
.text
@ -115,11 +116,13 @@ ostd_jump_fcontext:
std %r25, 96(%r1) # save R25
std %r26, 104(%r1) # save R26
std %r27, 112(%r1) # save R27
std %r29, 120(%r1) # save R28
std %r28, 120(%r1) # save R28
std %r29, 128(%r1) # save R29
std %r30, 136(%r1) # save R30
std %r31, 144(%r1) # save R31
#if _CALL_ELF != 2
std %r3, 152(%r1) # save hidden
#endif
# save CR
mfcr %r0
@ -133,10 +136,13 @@ ostd_jump_fcontext:
# store RSP (pointing to context-data) in R6
mr %r6, %r1
#if _CALL_ELF == 2
# restore RSP (pointing to context-data) from R3
mr %r1, %r3
#else
# restore RSP (pointing to context-data) from R4
mr %r1, %r4
#if _CALL_ELF != 2
ld %r2, 0(%r1) # restore TOC
#endif
ld %r14, 8(%r1) # restore R14
@ -157,7 +163,9 @@ ostd_jump_fcontext:
ld %r29, 128(%r1) # restore R29
ld %r30, 136(%r1) # restore R30
ld %r31, 144(%r1) # restore R31
#if _CALL_ELF != 2
ld %r3, 152(%r1) # restore hidden
#endif
# restore CR
ld %r0, 160(%r1)
@ -174,15 +182,33 @@ ostd_jump_fcontext:
# adjust stack
addi %r1, %r1, 184
#if _CALL_ELF == 2
# copy transfer_t into transfer_fn arg registers
mr %r3, %r6
# arg pointer already in %r4
# jump to context
bctr
.size ostd_jump_fcontext, .-ostd_jump_fcontext
#else
# zero in r3 indicates first jump to context-function
cmpdi %r3, 0
beq use_entry_arg
# return transfer_t
std %r6, 0(%r3)
std %r5, 8(%r3)
# jump to context
bctr
#if _CALL_ELF == 2
.size ostd_jump_fcontext, .-ostd_jump_fcontext
#else
use_entry_arg:
# copy transfer_t into transfer_fn arg registers
mr %r3, %r6
mr %r4, %r5
# jump to context
bctr
# ifdef _CALL_LINUX
.size .ostd_jump_fcontext, .-.L.ostd_jump_fcontext
# else

View File

@ -68,66 +68,66 @@
.text
.align 2
.globl ostd_jump_fcontext
.globl _ostd_jump_fcontext
_ostd_jump_fcontext:
; reserve space on stack
subi r1, r1, 184
std %r14, 8(%r1) ; save R14
std %r15, 16(%r1) ; save R15
std %r16, 24(%r1) ; save R16
std %r17, 32(%r1) ; save R17
std %r18, 40(%r1) ; save R18
std %r19, 48(%r1) ; save R19
std %r20, 56(%r1) ; save R20
std %r21, 64(%r1) ; save R21
std %r22, 72(%r1) ; save R22
std %r23, 80(%r1) ; save R23
std %r24, 88(%r1) ; save R24
std %r25, 96(%r1) ; save R25
std %r26, 104(%r1) ; save R26
std %r27, 112(%r1) ; save R27
std %r29, 120(%r1) ; save R28
std %r29, 128(%r1) ; save R29
std %r30, 136(%r1) ; save R30
std %r31, 144(%r1) ; save R31
std %r3, 152(%r1) ; save hidden
std r14, 8(r1) ; save R14
std r15, 16(r1) ; save R15
std r16, 24(r1) ; save R16
std r17, 32(r1) ; save R17
std r18, 40(r1) ; save R18
std r19, 48(r1) ; save R19
std r20, 56(r1) ; save R20
std r21, 64(r1) ; save R21
std r22, 72(r1) ; save R22
std r23, 80(r1) ; save R23
std r24, 88(r1) ; save R24
std r25, 96(r1) ; save R25
std r26, 104(r1) ; save R26
std r27, 112(r1) ; save R27
std r28, 120(r1) ; save R28
std r29, 128(r1) ; save R29
std r30, 136(r1) ; save R30
std r31, 144(r1) ; save R31
std r3, 152(r1) ; save hidden
; save CR
mfcr r0
std r0, 160(r1)
std r0, 160(r1)
; save LR
mflr r0
std r0, 168(r1)
std r0, 168(r1)
; save LR as PC
std r0, 176(r1)
std r0, 176(r1)
; store RSP (pointing to context-data) in R6
mr %r6, %r1
mr r6, r1
; restore RSP (pointing to context-data) from R4
mr r1, r4
ld %r14, 8(%r1) ; restore R14
ld %r15, 16(%r1) ; restore R15
ld %r16, 24(%r1) ; restore R16
ld %r17, 32(%r1) ; restore R17
ld %r18, 40(%r1) ; restore R18
ld %r19, 48(%r1) ; restore R19
ld %r20, 56(%r1) ; restore R20
ld %r21, 64(%r1) ; restore R21
ld %r22, 72(%r1) ; restore R22
ld %r23, 80(%r1) ; restore R23
ld %r24, 88(%r1) ; restore R24
ld %r25, 96(%r1) ; restore R25
ld %r26, 104(%r1) ; restore R26
ld %r27, 112(%r1) ; restore R27
ld %r28, 120(%r1) ; restore R28
ld %r29, 128(%r1) ; restore R29
ld %r30, 136(%r1) ; restore R30
ld %r31, 144(%r1) ; restore R31
ld %r3, 152(%r1) ; restore hidden
ld r14, 8(r1) ; restore R14
ld r15, 16(r1) ; restore R15
ld r16, 24(r1) ; restore R16
ld r17, 32(r1) ; restore R17
ld r18, 40(r1) ; restore R18
ld r19, 48(r1) ; restore R19
ld r20, 56(r1) ; restore R20
ld r21, 64(r1) ; restore R21
ld r22, 72(r1) ; restore R22
ld r23, 80(r1) ; restore R23
ld r24, 88(r1) ; restore R24
ld r25, 96(r1) ; restore R25
ld r26, 104(r1) ; restore R26
ld r27, 112(r1) ; restore R27
ld r28, 120(r1) ; restore R28
ld r29, 128(r1) ; restore R29
ld r30, 136(r1) ; restore R30
ld r31, 144(r1) ; restore R31
ld r3, 152(r1) ; restore hidden
; restore CR
ld r0, 160(r1)
@ -137,16 +137,28 @@ _ostd_jump_fcontext:
mtlr r0
; load PC
ld r0, 176(r1)
; restore CTR
mtctr r0
ld r12, 176(r1)
# restore CTR
mtctr r12
; adjust stack
# adjust stack
addi r1, r1, 184
; return transfer_t
std %r6, 0(%r3)
std %r5, 8(%r3)
# zero in r3 indicates first jump to context-function
cmpdi r3, 0
beq use_entry_arg
; jump to context
# return transfer_t
std r6, 0(r3)
std r5, 8(r3)
# jump to context
bctr
use_entry_arg:
# copy transfer_t into transfer_fn arg registers
mr r3, r6
mr r4, r5
# jump to context
bctr

View File

@ -1,3 +1,11 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
.align 2
.globl .ostd_jump_fcontext
.ostd_jump_fcontext:

View File

@ -66,6 +66,7 @@
* *
*******************************************************/
.file "make_ppc64_sysv_elf_gas.S"
.globl ostd_make_fcontext
#if _CALL_ELF == 2
.text
@ -124,10 +125,10 @@ ostd_make_fcontext:
li %r0, 0
std %r0, 184(%r3)
# compute address of returned transfer_t
addi %r0, %r3, 232
mr %r4, %r0
std %r4, 152(%r3)
#if _CALL_ELF != 2
# zero in r3 indicates first jump to context-function
std %r0, 152(%r3)
#endif
# load LR
mflr %r0

View File

@ -1,3 +1,9 @@
/*
Copyright Oliver Kowalke 2009.
Distributed under the Boost Software License, Version 1.0.
(See accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)
*/
.globl ostd_make_fcontext[DS]
.globl .ostd_make_fcontext[PR]
.align 2

View File

@ -66,6 +66,7 @@
* *
*******************************************************/
.file "ontop_ppc64_sysv_elf_gas.S"
.globl ostd_ontop_fcontext
#if _CALL_ELF == 2
.text
@ -115,11 +116,13 @@ ostd_ontop_fcontext:
std %r25, 96(%r1) # save R25
std %r26, 104(%r1) # save R26
std %r27, 112(%r1) # save R27
std %r29, 120(%r1) # save R28
std %r28, 120(%r1) # save R28
std %r29, 128(%r1) # save R29
std %r30, 136(%r1) # save R30
std %r31, 144(%r1) # save R31
#if _CALL_ELF != 2
std %r3, 152(%r1) # save hidden
#endif
# save CR
mfcr %r0
@ -133,12 +136,14 @@ ostd_ontop_fcontext:
# store RSP (pointing to context-data) in R7
mr %r7, %r1
#if _CALL_ELF == 2
# restore RSP (pointing to context-data) from R3
mr %r1, %r3
#else
# restore RSP (pointing to context-data) from R4
mr %r1, %r4
#if _CALL_ELF != 2
ld %r2, 0(%r1) # restore TOC
#endif
ld %r14, 8(%r1) # restore R14
ld %r15, 16(%r1) # restore R15
ld %r16, 24(%r1) # restore R16
@ -157,31 +162,73 @@ ostd_ontop_fcontext:
ld %r29, 128(%r1) # restore R29
ld %r30, 136(%r1) # restore R30
ld %r31, 144(%r1) # restore R31
ld %r4, 152(%r1) # restore hidden
#if _CALL_ELF != 2
ld %r3, 152(%r1) # restore hidden
#endif
# restore CR
ld %r0, 160(%r1)
mtcr %r0
#if _CALL_ELF == 2
# restore CTR
mtctr %r5
# copy transfer_t into ontop_fn arg registers
mr %r3, %r7
# arg pointer already in %r4
#else
# copy transfer_t into ontop_fn arg registers
mr %r4, %r7
# arg pointer already in %r5
# hidden arg already in %r3
# restore CTR
ld %r7, 0(%r6)
mtctr %r7
# restore TOC
ld %r2, 8(%r6)
# zero in r3 indicates first jump to context-function
cmpdi %r3, 0
beq use_entry_arg
#endif
return_to_ctx:
# restore LR
ld %r0, 168(%r1)
mtlr %r0
# ignore PC
# adjust stack
addi %r1, %r1, 184
# return transfer_t
std %r7, 0(%r4)
std %r5, 8(%r4)
# restore CTR
mtctr %r6
# jump to context
bctr
#if _CALL_ELF == 2
.size ostd_ontop_fcontext, .-ostd_ontop_fcontext
#else
use_entry_arg:
# compute return-value struct address
# (passed has hidden arg to ontop_fn)
addi %r3, %r1, 8
# jump to context and update LR
bctrl
# restore CTR
ld %r7, 176(%r1)
mtctr %r7
#if _CALL_ELF != 2
# restore TOC
ld %r2, 0(%r1)
#endif
# copy returned transfer_t into entry_fn arg registers
ld %r3, 8(%r1)
ld %r4, 16(%r1)
b return_to_ctx
# ifdef _CALL_LINUX
.size .ostd_ontop_fcontext, .-.L.ostd_ontop_fcontext
# else

View File

@ -68,66 +68,66 @@
.text
.align 2
.globl ostd_ontop_fcontext
.globl _ostd_ontop_fcontext
_ostd_ontop_fcontext:
; reserve space on stack
subi r1, r1, 184
std %r14, 8(%r1) ; save R14
std %r15, 16(%r1) ; save R15
std %r16, 24(%r1) ; save R16
std %r17, 32(%r1) ; save R17
std %r18, 40(%r1) ; save R18
std %r19, 48(%r1) ; save R19
std %r20, 56(%r1) ; save R20
std %r21, 64(%r1) ; save R21
std %r22, 72(%r1) ; save R22
std %r23, 80(%r1) ; save R23
std %r24, 88(%r1) ; save R24
std %r25, 96(%r1) ; save R25
std %r26, 104(%r1) ; save R26
std %r27, 112(%r1) ; save R27
std %r29, 120(%r1) ; save R28
std %r29, 128(%r1) ; save R29
std %r30, 136(%r1) ; save R30
std %r31, 144(%r1) ; save R31
std %r3, 152(%r1) ; save hidden
std r14, 8(r1) ; save R14
std r15, 16(r1) ; save R15
std r16, 24(r1) ; save R16
std r17, 32(r1) ; save R17
std r18, 40(r1) ; save R18
std r19, 48(r1) ; save R19
std r20, 56(r1) ; save R20
std r21, 64(r1) ; save R21
std r22, 72(r1) ; save R22
std r23, 80(r1) ; save R23
std r24, 88(r1) ; save R24
std r25, 96(r1) ; save R25
std r26, 104(r1) ; save R26
std r27, 112(r1) ; save R27
std r28, 120(r1) ; save R28
std r29, 128(r1) ; save R29
std r30, 136(r1) ; save R30
std r31, 144(r1) ; save R31
std r3, 152(r1) ; save hidden
; save CR
mfcr r0
std r0, 160(r1)
std r0, 160(r1)
; save LR
mflr r0
std r0, 168(r1)
std r0, 168(r1)
; save LR as PC
std r0, 176(r1)
std r0, 176(r1)
; store RSP (pointing to context-data) in R7
mr %r7, %r1
mr r7, r1
; restore RSP (pointing to context-data) from R4
mr r1, r4
ld %r14, 8(%r1) ; restore R14
ld %r15, 16(%r1) ; restore R15
ld %r16, 24(%r1) ; restore R16
ld %r17, 32(%r1) ; restore R17
ld %r18, 40(%r1) ; restore R18
ld %r19, 48(%r1) ; restore R19
ld %r20, 56(%r1) ; restore R20
ld %r21, 64(%r1) ; restore R21
ld %r22, 72(%r1) ; restore R22
ld %r23, 80(%r1) ; restore R23
ld %r24, 88(%r1) ; restore R24
ld %r25, 96(%r1) ; restore R25
ld %r26, 104(%r1) ; restore R26
ld %r27, 112(%r1) ; restore R27
ld %r28, 120(%r1) ; restore R28
ld %r29, 128(%r1) ; restore R29
ld %r30, 136(%r1) ; restore R30
ld %r31, 144(%r1) ; restore R31
ld %r4, 152(%r1) ; restore hidden
ld r14, 8(r1) ; restore R14
ld r15, 16(r1) ; restore R15
ld r16, 24(r1) ; restore R16
ld r17, 32(r1) ; restore R17
ld r18, 40(r1) ; restore R18
ld r19, 48(r1) ; restore R19
ld r20, 56(r1) ; restore R20
ld r21, 64(r1) ; restore R21
ld r22, 72(r1) ; restore R22
ld r23, 80(r1) ; restore R23
ld r24, 88(r1) ; restore R24
ld r25, 96(r1) ; restore R25
ld r26, 104(r1) ; restore R26
ld r27, 112(r1) ; restore R27
ld r28, 120(r1) ; restore R28
ld r29, 128(r1) ; restore R29
ld r30, 136(r1) ; restore R30
ld r31, 144(r1) ; restore R31
ld r4, 152(r1) ; restore hidden
; restore CR
ld r0, 160(r1)
@ -141,8 +141,8 @@ _ostd_ontop_fcontext:
addi r1, r1, 184
; return transfer_t
std %r7, 0(%r4)
std %r5, 8(%r4)
std r7, 0(r4)
std r5, 8(r4)
; restore CTR
mtctr r6

View File

@ -1,6 +1,6 @@
.align 2
.globl .ostd_jump_fcontext
.ostd_jump_fcontext:
.globl .ostd_ontop_fcontext
.ostd_ontop_fcontext:
# reserve space on stack
subi 1, 1, 184

View File

@ -97,6 +97,7 @@ ostd_jump_fcontext:
leaq -0x118(%rsp), %rsp /* prepare stack */
#if !defined(OSTD_USE_TSX)
/* save XMM storage */
movaps %xmm6, 0x0(%rsp)
movaps %xmm7, 0x10(%rsp)
@ -110,11 +111,12 @@ ostd_jump_fcontext:
movaps %xmm15, 0x90(%rsp)
stmxcsr 0xa0(%rsp) /* save MMX control- and status-word */
fnstcw 0xa4(%rsp) /* save x87 control-word */
#endif
/* load NT_TIB */
movq %gs:(0x30), %r10
/* save fiber local storage */
movq 0x18(%r10), %rax
movq 0x20(%r10), %rax
movq %rax, 0xb0(%rsp)
/* save current deallocation stack */
movq 0x1478(%r10), %rax
@ -143,7 +145,8 @@ ostd_jump_fcontext:
/* restore RSP (pointing to context-data) from RDX */
movq %rdx, %rsp
/* save XMM storage */
#if !defined(OSTD_USE_TSX)
/* restore XMM storage */
movaps 0x0(%rsp), %xmm6
movaps 0x10(%rsp), %xmm7
movaps 0x20(%rsp), %xmm8
@ -154,12 +157,15 @@ ostd_jump_fcontext:
movaps 0x70(%rsp), %xmm13
movaps 0x80(%rsp), %xmm14
movaps 0x90(%rsp), %xmm15
ldmxcsr 0xa0(%rsp) /* restore MMX control- and status-word */
fldcw 0xa4(%rsp) /* restore x87 control-word */
#endif
/* load NT_TIB */
movq %gs:(0x30), %r10
/* restore fiber local storage */
movq 0xb0(%rsp), %rax
movq %rax, 0x18(%r10)
movq %rax, 0x20(%r10)
/* restore current deallocation stack */
movq 0xb8(%rsp), %rax
movq %rax, 0x1478(%r10)

View File

@ -90,6 +90,7 @@ ostd_jump_fcontext PROC OSTD_CONTEXT_EXPORT FRAME
; prepare stack
lea rsp, [rsp-0118h]
IFNDEF OSTD_USE_TSX
; save XMM storage
movaps [rsp], xmm6
movaps [rsp+010h], xmm7
@ -105,11 +106,12 @@ ostd_jump_fcontext PROC OSTD_CONTEXT_EXPORT FRAME
stmxcsr [rsp+0a0h]
; save x87 control-word
fnstcw [rsp+0a4h]
ENDIF
; load NT_TIB
mov r10, gs:[030h]
; save fiber local storage
mov rax, [r10+018h]
mov rax, [r10+020h]
mov [rsp+0b0h], rax
; save current deallocation stack
mov rax, [r10+01478h]
@ -138,6 +140,7 @@ ostd_jump_fcontext PROC OSTD_CONTEXT_EXPORT FRAME
; restore RSP (pointing to context-data) from RDX
mov rsp, rdx
IFNDEF OSTD_USE_TSX
; restore XMM storage
movaps xmm6, [rsp]
movaps xmm7, [rsp+010h]
@ -153,12 +156,13 @@ ostd_jump_fcontext PROC OSTD_CONTEXT_EXPORT FRAME
ldmxcsr [rsp+0a0h]
; save x87 control-word
fldcw [rsp+0a4h]
ENDIF
; load NT_TIB
mov r10, gs:[030h]
; restore fiber local storage
mov rax, [rsp+0b0h]
mov [r10+018h], rax
mov [r10+020h], rax
; restore current deallocation stack
mov rax, [rsp+0b8h]
mov [r10+01478h], rax

View File

@ -24,6 +24,7 @@
* *
****************************************************************************************/
.file "jump_x86_64_sysv_elf_gas.S"
.text
.globl ostd_jump_fcontext
.type ostd_jump_fcontext,@function
@ -31,8 +32,10 @@
ostd_jump_fcontext:
leaq -0x38(%rsp), %rsp /* prepare stack */
#if !defined(OSTD_USE_TSX)
stmxcsr (%rsp) /* save MMX control- and status-word */
fnstcw 0x4(%rsp) /* save x87 control-word */
#endif
movq %r12, 0x8(%rsp) /* save R12 */
movq %r13, 0x10(%rsp) /* save R13 */
@ -49,8 +52,10 @@ ostd_jump_fcontext:
movq 0x38(%rsp), %r8 /* restore return-address */
#if !defined(OSTD_USE_TSX)
ldmxcsr (%rsp) /* restore MMX control- and status-word */
fldcw 0x4(%rsp) /* restore x87 control-word */
#endif
movq 0x8(%rsp), %r12 /* restore R12 */
movq 0x10(%rsp), %r13 /* restore R13 */

View File

@ -30,8 +30,10 @@
_ostd_jump_fcontext:
leaq -0x38(%rsp), %rsp /* prepare stack */
#if !defined(OSTD_USE_TSX)
stmxcsr (%rsp) /* save MMX control- and status-word */
fnstcw 0x4(%rsp) /* save x87 control-word */
#endif
movq %r12, 0x8(%rsp) /* save R12 */
movq %r13, 0x10(%rsp) /* save R13 */
@ -48,8 +50,10 @@ _ostd_jump_fcontext:
movq 0x38(%rsp), %r8 /* restore return-address */
#if !defined(OSTD_USE_TSX)
ldmxcsr (%rsp) /* restore MMX control- and status-word */
fldcw 0x4(%rsp) /* restore x87 control-word */
#endif
movq 0x8(%rsp), %r12 /* restore R12 */
movq 0x10(%rsp), %r13 /* restore R13 */

View File

@ -125,6 +125,11 @@ ostd_make_fcontext:
xorq %rcx, %rcx
movq %rcx, 0xb0(%rax)
/* save MMX control- and status-word */
stmxcsr 0xa0(%rax)
/* save x87 control-word */
fnstcw 0xa4(%rax)
/* compute address of transport_t */
leaq 0x140(%rax), %rcx
/* store address of transport_t in hidden field */

View File

@ -24,6 +24,7 @@
* *
****************************************************************************************/
.file "make_x86_64_sysv_elf_gas.S"
.text
.globl ostd_make_fcontext
.type ostd_make_fcontext,@function

View File

@ -97,6 +97,7 @@ ostd_ontop_fcontext:
leaq -0x118(%rsp), %rsp /* prepare stack */
#if !defined(OSTD_USE_TSX)
/* save XMM storage */
movaps %xmm6, 0x0(%rsp)
movaps %xmm7, 0x10(%rsp)
@ -110,11 +111,12 @@ ostd_ontop_fcontext:
movaps %xmm15, 0x90(%rsp)
stmxcsr 0xa0(%rsp) /* save MMX control- and status-word */
fnstcw 0xa4(%rsp) /* save x87 control-word */
#endif
/* load NT_TIB */
movq %gs:(0x30), %r10
/* save fiber local storage */
movq 0x18(%r10), %rax
movq 0x20(%r10), %rax
movq %rax, 0xb0(%rsp)
/* save current deallocation stack */
movq 0x1478(%r10), %rax
@ -143,7 +145,8 @@ ostd_ontop_fcontext:
/* restore RSP (pointing to context-data) from RDX */
movq %rdx, %rsp
/* save XMM storage */
#if !defined(OSTD_USE_TSX)
/* restore XMM storage */
movaps 0x0(%rsp), %xmm6
movaps 0x10(%rsp), %xmm7
movaps 0x20(%rsp), %xmm8
@ -154,12 +157,15 @@ ostd_ontop_fcontext:
movaps 0x70(%rsp), %xmm13
movaps 0x80(%rsp), %xmm14
movaps 0x90(%rsp), %xmm15
ldmxcsr 0xa0(%rsp) /* restore MMX control- and status-word */
fldcw 0xa4(%rsp) /* restore x87 control-word */
#endif
/* load NT_TIB */
movq %gs:(0x30), %r10
/* restore fiber local storage */
movq 0xb0(%rsp), %rax
movq %rax, 0x18(%r10)
movq %rax, 0x20(%r10)
/* restore current deallocation stack */
movq 0xb8(%rsp), %rax
movq %rax, 0x1478(%r10)

View File

@ -90,6 +90,7 @@ ostd_ontop_fcontext PROC OSTD_CONTEXT_EXPORT FRAME
; prepare stack
lea rsp, [rsp-0118h]
IFNDEF OSTD_USE_TSX
; save XMM storage
movaps [rsp], xmm6
movaps [rsp+010h], xmm7
@ -105,11 +106,12 @@ ostd_ontop_fcontext PROC OSTD_CONTEXT_EXPORT FRAME
stmxcsr [rsp+0a0h]
; save x87 control-word
fnstcw [rsp+0a4h]
ENDIF
; load NT_TIB
mov r10, gs:[030h]
; save fiber local storage
mov rax, [r10+018h]
mov rax, [r10+020h]
mov [rsp+0b0h], rax
; save current deallocation stack
mov rax, [r10+01478h]
@ -138,6 +140,7 @@ ostd_ontop_fcontext PROC OSTD_CONTEXT_EXPORT FRAME
; restore RSP (pointing to context-data) from RDX
mov rsp, rdx
IFNDEF OSTD_USE_TSX
; restore XMM storage
movaps xmm6, [rsp]
movaps xmm7, [rsp+010h]
@ -153,12 +156,13 @@ ostd_ontop_fcontext PROC OSTD_CONTEXT_EXPORT FRAME
ldmxcsr [rsp+0a0h]
; save x87 control-word
fldcw [rsp+0a4h]
ENDIF
; load NT_TIB
mov r10, gs:[030h]
; restore fiber local storage
mov rax, [rsp+0b0h]
mov [r10+018h], rax
mov [r10+020h], rax
; restore current deallocation stack
mov rax, [rsp+0b8h]
mov [r10+01478h], rax

View File

@ -24,6 +24,7 @@
* *
****************************************************************************************/
.file "ontop_x86_64_sysv_elf_gas.S"
.text
.globl ostd_ontop_fcontext
.type ostd_ontop_fcontext,@function
@ -34,8 +35,10 @@ ostd_ontop_fcontext:
leaq -0x38(%rsp), %rsp /* prepare stack */
#if !defined(OSTD_USE_TSX)
stmxcsr (%rsp) /* save MMX control- and status-word */
fnstcw 0x4(%rsp) /* save x87 control-word */
#endif
movq %r12, 0x8(%rsp) /* save R12 */
movq %r13, 0x10(%rsp) /* save R13 */
@ -50,8 +53,10 @@ ostd_ontop_fcontext:
/* restore RSP (pointing to context-data) from RDI */
movq %rdi, %rsp
#if !defined(OSTD_USE_TSX)
ldmxcsr (%rsp) /* restore MMX control- and status-word */
fldcw 0x4(%rsp) /* restore x87 control-word */
#endif
movq 0x8(%rsp), %r12 /* restore R12 */
movq 0x10(%rsp), %r13 /* restore R13 */

View File

@ -33,8 +33,10 @@ _ostd_ontop_fcontext:
leaq -0x38(%rsp), %rsp /* prepare stack */
#if !defined(OSTD_USE_TSX)
stmxcsr (%rsp) /* save MMX control- and status-word */
fnstcw 0x4(%rsp) /* save x87 control-word */
#endif
movq %r12, 0x8(%rsp) /* save R12 */
movq %r13, 0x10(%rsp) /* save R13 */
@ -49,8 +51,10 @@ _ostd_ontop_fcontext:
/* restore RSP (pointing to context-data) from RDI */
movq %rdi, %rsp
#if !defined(OSTD_USE_TSX)
ldmxcsr (%rsp) /* restore MMX control- and status-word */
fldcw 0x4(%rsp) /* restore x87 control-word */
#endif
movq 0x8(%rsp), %r12 /* restore R12 */
movq 0x10(%rsp), %r13 /* restore R13 */