2N/A/*
2N/A * CDDL HEADER START
2N/A *
2N/A * The contents of this file are subject to the terms of the
2N/A * Common Development and Distribution License (the "License").
2N/A * You may not use this file except in compliance with the License.
2N/A *
2N/A * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
2N/A * or http://www.opensolaris.org/os/licensing.
2N/A * See the License for the specific language governing permissions
2N/A * and limitations under the License.
2N/A *
2N/A * When distributing Covered Code, include this CDDL HEADER in each
2N/A * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
2N/A * If applicable, add the following below this CDDL HEADER, with the
2N/A * fields enclosed by brackets "[]" replaced with your own identifying
2N/A * information: Portions Copyright [yyyy] [name of copyright owner]
2N/A *
2N/A * CDDL HEADER END
2N/A */
2N/A
2N/A/*
2N/A * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
2N/A */
2N/A
2N/A .file "asm_subr.s"
2N/A
2N/A#include "SYS.h"
2N/A#include <sys/trap.h>
2N/A#include <../assym.h>
2N/A
2N/A ! This is where execution resumes when a thread created with
2N/A ! thr_create() or pthread_create() returns (see setup_context()).
2N/A ! We pass the (void *) return value to _thrp_terminate().
2N/A ENTRY(_lwp_start)
2N/A nop ! this is the location from which the func() was "called"
2N/A nop
2N/A call _thrp_terminate ! %o0 contains the return value
2N/A nop
2N/A SET_SIZE(_lwp_start)
2N/A
2N/A ENTRY(_lwp_terminate)
2N/A ! Flush the register windows so the stack can be reused.
2N/A ta ST_FLUSH_WINDOWS
2N/A ! All we need to do now is (carefully) call lwp_exit().
2N/A mov SYS_lwp_exit, %g1
2N/A ta SYSCALL_TRAPNUM
2N/A RET ! if we return, it is very bad
2N/A SET_SIZE(_lwp_terminate)
2N/A
2N/A ENTRY(set_curthread)
2N/A retl
2N/A mov %o0, %g7
2N/A SET_SIZE(set_curthread)
2N/A
2N/A#ifdef __sparcv9
2N/A#define GREGSIZE 8
2N/A#else
2N/A#define GREGSIZE 4
2N/A#endif
2N/A ! void _fetch_globals(greg_t *);
2N/A ! (called from siglongjmp())
2N/A ENTRY(_fetch_globals)
2N/A stn %g1, [%o0 + 0*GREGSIZE]
2N/A stn %g2, [%o0 + 1*GREGSIZE]
2N/A stn %g3, [%o0 + 2*GREGSIZE]
2N/A stn %g4, [%o0 + 3*GREGSIZE]
2N/A stn %g5, [%o0 + 4*GREGSIZE]
2N/A stn %g6, [%o0 + 5*GREGSIZE]
2N/A retl
2N/A stn %g7, [%o0 + 6*GREGSIZE]
2N/A SET_SIZE(_fetch_globals)
2N/A
2N/A#ifdef __sparcv9
2N/A ENTRY(_getfprs)
2N/A retl
2N/A mov %fprs, %o0
2N/A SET_SIZE(_getfprs)
2N/A#else
2N/A ENTRY(_getpsr)
2N/A retl
2N/A ta ST_GETPSR
2N/A SET_SIZE(_getpsr)
2N/A
2N/A ENTRY(_do_fix_align)
2N/A retl
2N/A ta ST_FIX_ALIGN
2N/A SET_SIZE(_do_fix_align)
2N/A#endif
2N/A
2N/A ENTRY(_getfsr)
2N/A retl
2N/A stn %fsr, [%o0]
2N/A SET_SIZE(_getfsr)
2N/A
2N/A ENTRY(_setfsr)
2N/A retl
2N/A ldn [%o0], %fsr
2N/A SET_SIZE(_setfsr)
2N/A
2N/A ENTRY(_flush_windows)
2N/A retl
2N/A ta ST_FLUSH_WINDOWS
2N/A SET_SIZE(_flush_windows)
2N/A
2N/A ENTRY(__lwp_park)
2N/A mov %o1, %o2
2N/A mov %o0, %o1
2N/A mov 0, %o0
2N/A SYSTRAP_RVAL1(lwp_park)
2N/A SYSLWPERR
2N/A RET
2N/A SET_SIZE(__lwp_park)
2N/A
2N/A ENTRY(__lwp_unpark)
2N/A mov %o0, %o1
2N/A mov 1, %o0
2N/A SYSTRAP_RVAL1(lwp_park)
2N/A SYSLWPERR
2N/A RET
2N/A SET_SIZE(__lwp_unpark)
2N/A
2N/A ENTRY(__lwp_unpark_all)
2N/A mov %o1, %o2
2N/A mov %o0, %o1
2N/A mov 2, %o0
2N/A SYSTRAP_RVAL1(lwp_park)
2N/A SYSLWPERR
2N/A RET
2N/A SET_SIZE(__lwp_unpark_all)
2N/A
2N/A/*
2N/A * __sighndlr(int sig, siginfo_t *si, ucontex_t *uc, void (*hndlr)())
2N/A *
2N/A * This is called from sigacthandler() for the entire purpose of
2N/A * communicating the ucontext to java's stack tracing functions.
2N/A */
2N/A ENTRY(__sighndlr)
2N/A .globl __sighndlrend
2N/A save %sp, -SA(MINFRAME), %sp
2N/A mov %i0, %o0
2N/A mov %i1, %o1
2N/A jmpl %i3, %o7
2N/A mov %i2, %o2
2N/A ret
2N/A restore
2N/A__sighndlrend:
2N/A SET_SIZE(__sighndlr)
2N/A
2N/A/*
2N/A * int _sigsetjmp(sigjmp_buf env, int savemask)
2N/A *
2N/A * This version is faster than the old non-threaded version because we
2N/A * don't normally have to call __getcontext() to get the signal mask.
2N/A * (We have a copy of it in the ulwp_t structure.)
2N/A */
2N/A
2N/A#undef sigsetjmp
2N/A
2N/A ENTRY2(sigsetjmp,_sigsetjmp)
2N/A stn %sp, [%o0 + SJS_SP] ! save caller's sp into env->sjs_sp
2N/A add %o7, 8, %o2 ! calculate caller's return pc
2N/A stn %o2, [%o0 + SJS_PC] ! save caller's pc into env->sjs_pc
2N/A stn %fp, [%o0 + SJS_FP] ! save caller's return linkage
2N/A stn %i7, [%o0 + SJS_I7]
2N/A#ifdef __sparcv9
2N/A rd %asi, %o3
2N/A rd %fprs, %o4
2N/A stx %o3, [%o0 + SJS_ASI]
2N/A stx %o4, [%o0 + SJS_FPRS]
2N/A#endif
2N/A call __csigsetjmp
2N/A sub %o2, 8, %o7 ! __csigsetjmp returns to caller
2N/A SET_SIZE(sigsetjmp)
2N/A SET_SIZE(_sigsetjmp)