1/*
2       Copyright Claudio Jeker 2024
3   Distributed under the Boost Software License, Version 1.0.
4      (See accompanying file LICENSE_1_0.txt or copy at
5          http://www.boost.org/LICENSE_1_0.txt)
6*/
7
8/*
9 * typedef struct {
10 *	void *handle;
11 *	zend_fiber_transfer *transfer;
12 * } boost_context_data;
13 *
14 * boost_context_data jump_fcontext(void *to, zend_fiber_transfer *transfer);
15 */
16#define CC64FSZ 176
17#define BIAS 2047
18#define SP 128
19#define I7 136
20
21.file "jump_sparc64_sysv_elf_gas.S"
22.text
23.align  4
24.global jump_fcontext
25.type   jump_fcontext, %function
26jump_fcontext:
27	# prepare stack
28	save	%sp, -CC64FSZ, %sp
29
30	# store framepointer and return address in slots reserved
31	# for arguments
32	stx %fp, [%sp + BIAS + SP]
33	stx %i7, [%sp + BIAS + I7]
34	mov %sp, %o0
35	# force flush register windows to stack and with that save context
36	flushw
37	# get SP (pointing to new context-data) from %i0 param
38	mov %i0, %sp
39	# load framepointer and return address from context
40	ldx [%sp + BIAS + SP], %fp
41	ldx [%sp + BIAS + I7], %i7
42
43	ret
44	 restore %o0, %g0, %o0
45	# restore old %sp (pointing to old context-data) in %o0
46	# *data stored in %o1 was not modified
47.size	jump_fcontext,.-jump_fcontext
48# Mark that we don't need executable stack.
49.section .note.GNU-stack,"",%progbits
50