hjl / source-git / glibc

Forked from source-git/glibc 3 years ago
Clone

Blame sysdeps/unix/sysv/linux/alpha/makecontext.S

Packit 6c4009
/* Copyright (C) 2004-2018 Free Software Foundation, Inc.
Packit 6c4009
   This file is part of the GNU C Library.
Packit 6c4009
Packit 6c4009
   The GNU C Library is free software; you can redistribute it and/or
Packit 6c4009
   modify it under the terms of the GNU Lesser General Public
Packit 6c4009
   License as published by the Free Software Foundation; either
Packit 6c4009
   version 2.1 of the License, or (at your option) any later version.
Packit 6c4009
Packit 6c4009
   The GNU C Library is distributed in the hope that it will be useful,
Packit 6c4009
   but WITHOUT ANY WARRANTY; without even the implied warranty of
Packit 6c4009
   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Packit 6c4009
   Lesser General Public License for more details.
Packit 6c4009
Packit 6c4009
   You should have received a copy of the GNU Lesser General Public
Packit 6c4009
   License along with the GNU C Library.  If not, see
Packit 6c4009
   <http://www.gnu.org/licenses/>.  */
Packit 6c4009
Packit 6c4009
#include <sysdep.h>
Packit 6c4009
#include <ucontext-offsets.h>
Packit 6c4009
Packit 6c4009
Packit 6c4009
ENTRY(__makecontext)
Packit 6c4009
	ldgp	$29, 0($27)
Packit 6c4009
#ifdef PROF
Packit 6c4009
	.set noat
Packit 6c4009
	lda     AT, _mcount
Packit 6c4009
	jsr     AT, (AT), _mcount
Packit 6c4009
	.set at
Packit 6c4009
#endif
Packit 6c4009
	.prologue 1
Packit 6c4009
Packit 6c4009
	/* Compute top of stack, including arguments.  */
Packit 6c4009
	ldq	$1, UC_STACK+SS_SP($16)
Packit 6c4009
	ldq	$2, UC_STACK+SS_SIZE($16)
Packit 6c4009
	addq	$1, $2, $8
Packit 6c4009
	subq	$18, 6, $1
Packit 6c4009
	cmovlt	$1, 0, $1
Packit 6c4009
	s8addq	$1, 0, $2
Packit 6c4009
	subq	$8, $2, $8
Packit 6c4009
Packit 6c4009
	/* Copy all parameters.  Switch statement header here.  */
Packit 6c4009
	ldah	$3, $jumptable($29)	!gprelhigh
Packit 6c4009
	cmple	$18, 6, $1
Packit 6c4009
	mov	$18, $2
Packit 6c4009
	cmoveq	$1, 7, $2
Packit 6c4009
	s4addq	$2, $3, $3
Packit 6c4009
	ldl	$4, $jumptable($3)	!gprellow
Packit 6c4009
	addq	$4, $29, $4
Packit 6c4009
	jmp	$31, ($4), $args1
Packit 6c4009
Packit 6c4009
	.section .rodata
Packit 6c4009
	.align	2
Packit 6c4009
$jumptable:
Packit 6c4009
	.gprel32  $args0
Packit 6c4009
	.gprel32  $args1
Packit 6c4009
	.gprel32  $args2
Packit 6c4009
	.gprel32  $args3
Packit 6c4009
	.gprel32  $args4
Packit 6c4009
	.gprel32  $args5
Packit 6c4009
	.gprel32  $args6
Packit 6c4009
	.gprel32  $argsN
Packit 6c4009
	.text
Packit 6c4009
Packit 6c4009
	/* Here we process arguments 7 through N.  This is a straight
Packit 6c4009
	   stack-to-stack copy.  */
Packit 6c4009
	.align	4
Packit 6c4009
$argsN:
Packit 6c4009
	subq	$18, 6, $1
Packit 6c4009
	lda	$2, 0($8)
Packit 6c4009
	lda	$3, 3*8($30)
Packit 6c4009
	.align	4
Packit 6c4009
1:
Packit 6c4009
	ldq	$0, 0($3)
Packit 6c4009
	subq	$1, 1, $1
Packit 6c4009
	lda	$3, 8($3)
Packit 6c4009
	stq	$0, 0($2)
Packit 6c4009
	lda	$2, 8($2)
Packit 6c4009
	bne	$1, 1b
Packit 6c4009
Packit 6c4009
	/* Here we process arguments 6 through 0.  This involves
Packit 6c4009
	   copying into the register save areas of the ucontext.  */
Packit 6c4009
	.align	4
Packit 6c4009
$args6:
Packit 6c4009
	ldq	$0, 2*8($30)
Packit 6c4009
	stq	$0, UC_SIGCTX+SC_REGS+21*8($16)
Packit 6c4009
	unop
Packit 6c4009
	stq	$0, UC_SIGCTX+SC_FPREGS+21*8($16)
Packit 6c4009
$args5:
Packit 6c4009
	ldq	$0, 1*8($30)
Packit 6c4009
	stq	$0, UC_SIGCTX+SC_REGS+20*8($16)
Packit 6c4009
	unop
Packit 6c4009
	stq	$0, UC_SIGCTX+SC_FPREGS+20*8($16)
Packit 6c4009
$args4:
Packit 6c4009
	ldq	$0, 0*8($30)
Packit 6c4009
	stq	$0, UC_SIGCTX+SC_REGS+19*8($16)
Packit 6c4009
	unop
Packit 6c4009
	stq	$0, UC_SIGCTX+SC_FPREGS+19*8($16)
Packit 6c4009
$args3:
Packit 6c4009
	unop
Packit 6c4009
	stq	$21, UC_SIGCTX+SC_REGS+18*8($16)
Packit 6c4009
	unop
Packit 6c4009
	stt	$f21, UC_SIGCTX+SC_FPREGS+18*8($16)
Packit 6c4009
$args2:
Packit 6c4009
	unop
Packit 6c4009
	stq	$20, UC_SIGCTX+SC_REGS+17*8($16)
Packit 6c4009
	unop
Packit 6c4009
	stt	$f20, UC_SIGCTX+SC_FPREGS+17*8($16)
Packit 6c4009
$args1:
Packit 6c4009
	unop
Packit 6c4009
	stq	$19, UC_SIGCTX+SC_REGS+16*8($16)
Packit 6c4009
	unop
Packit 6c4009
	stt	$f19, UC_SIGCTX+SC_FPREGS+16*8($16)
Packit 6c4009
$args0:
Packit 6c4009
Packit 6c4009
	/* Set up the registers ready to invoke __startcontext.
Packit 6c4009
	   We seed $27 with the target function address, and $9
Packit 6c4009
	   with the link from ucp.  */
Packit 6c4009
	ldah	$0, __startcontext($29)		!gprelhigh
Packit 6c4009
	ldq	$1, UC_LINK($16)
Packit 6c4009
	lda	$0, __startcontext($0)		!gprellow
Packit 6c4009
	stq	$17, UC_SIGCTX+SC_REGS+27*8($16)
Packit 6c4009
	stq	$8, UC_SIGCTX+SC_REGS+30*8($16)
Packit 6c4009
	stq	$0, UC_SIGCTX+SC_PC($16)
Packit 6c4009
	stq	$1, UC_SIGCTX+SC_REGS+9*8($16)
Packit 6c4009
Packit 6c4009
	/* No return value from makecontext.  */
Packit 6c4009
	ret
Packit 6c4009
Packit 6c4009
END(__makecontext)
Packit 6c4009
weak_alias (__makecontext, makecontext)
Packit 6c4009
Packit 6c4009
/* This function is where a new makecontext "thread" begins life.
Packit 6c4009
   We have already set up $27 for calling the target function, and
Packit 6c4009
   we've set $9 to the UC_LINK of the parent context.
Packit 6c4009
Packit 6c4009
   If the function returns, we either jump to the linked context
Packit 6c4009
   (if non-null) or exit.  */
Packit 6c4009
Packit 6c4009
	.align	4
Packit 6c4009
	.ent	__startcontext
Packit 6c4009
__startcontext:
Packit 6c4009
	.frame $31, 0, $31, 0
Packit 6c4009
	.prologue 0
Packit 6c4009
Packit 6c4009
	jsr	$26, ($27), 0
Packit 6c4009
	ldgp	$29, 0($26)
Packit 6c4009
	mov	$9, $16
Packit 6c4009
	beq	$9, 1f
Packit 6c4009
Packit 6c4009
#ifdef PIC
Packit 6c4009
	bsr	$26, __setcontext		!samegp
Packit 6c4009
1:	mov	$31, $16
Packit 6c4009
	bsr	$26, HIDDEN_JUMPTARGET(exit)	!samegp
Packit 6c4009
#else
Packit 6c4009
	jsr	$26, __setcontext
Packit 6c4009
	ldgp	$29, 0($26)
Packit 6c4009
1:	mov	$31, $16
Packit 6c4009
	jsr	$26, HIDDEN_JUMPTARGET(exit)
Packit 6c4009
#endif
Packit 6c4009
Packit 6c4009
	halt
Packit 6c4009
Packit 6c4009
	.end __startcontext