1*0Sstevel@tonic-gate/* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate/* 23*0Sstevel@tonic-gate * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate#pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate .file "asm_subr.s" 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate#include <sys/asm_linkage.h> 32*0Sstevel@tonic-gate#include <sys/trap.h> 33*0Sstevel@tonic-gate#include <../assym.h> 34*0Sstevel@tonic-gate#include "SYS.h" 35*0Sstevel@tonic-gate 36*0Sstevel@tonic-gate ! This is where execution resumes when a thread created with 37*0Sstevel@tonic-gate ! thr_create() or pthread_create() returns (see setup_context()). 38*0Sstevel@tonic-gate ! We pass the (void *) return value to _thr_terminate(). 39*0Sstevel@tonic-gate ENTRY(_lwp_start) 40*0Sstevel@tonic-gate nop ! this is the location from which the func() was "called" 41*0Sstevel@tonic-gate nop 42*0Sstevel@tonic-gate call _thr_terminate ! %o0 contains the return value 43*0Sstevel@tonic-gate nop 44*0Sstevel@tonic-gate SET_SIZE(_lwp_start) 45*0Sstevel@tonic-gate 46*0Sstevel@tonic-gate ENTRY(_lwp_terminate) 47*0Sstevel@tonic-gate ! Flush the register windows so the stack can be reused. 48*0Sstevel@tonic-gate ta ST_FLUSH_WINDOWS 49*0Sstevel@tonic-gate ! All we need to do now is (carefully) call lwp_exit(). 50*0Sstevel@tonic-gate mov SYS_lwp_exit, %g1 51*0Sstevel@tonic-gate ta SYSCALL_TRAPNUM 52*0Sstevel@tonic-gate RET ! if we return, it is very bad 53*0Sstevel@tonic-gate SET_SIZE(_lwp_terminate) 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate ENTRY(set_curthread) 56*0Sstevel@tonic-gate retl 57*0Sstevel@tonic-gate mov %o0, %g7 58*0Sstevel@tonic-gate SET_SIZE(set_curthread) 59*0Sstevel@tonic-gate 60*0Sstevel@tonic-gate#ifdef __sparcv9 61*0Sstevel@tonic-gate#define GREGSIZE 8 62*0Sstevel@tonic-gate#else 63*0Sstevel@tonic-gate#define GREGSIZE 4 64*0Sstevel@tonic-gate#endif 65*0Sstevel@tonic-gate ! void _fetch_globals(greg_t *); 66*0Sstevel@tonic-gate ! (called from siglongjmp()) 67*0Sstevel@tonic-gate ENTRY(_fetch_globals) 68*0Sstevel@tonic-gate stn %g1, [%o0 + 0*GREGSIZE] 69*0Sstevel@tonic-gate stn %g2, [%o0 + 1*GREGSIZE] 70*0Sstevel@tonic-gate stn %g3, [%o0 + 2*GREGSIZE] 71*0Sstevel@tonic-gate stn %g4, [%o0 + 3*GREGSIZE] 72*0Sstevel@tonic-gate stn %g5, [%o0 + 4*GREGSIZE] 73*0Sstevel@tonic-gate stn %g6, [%o0 + 5*GREGSIZE] 74*0Sstevel@tonic-gate retl 75*0Sstevel@tonic-gate stn %g7, [%o0 + 6*GREGSIZE] 76*0Sstevel@tonic-gate SET_SIZE(_fetch_globals) 77*0Sstevel@tonic-gate 78*0Sstevel@tonic-gate#ifdef __sparcv9 79*0Sstevel@tonic-gate ENTRY(_getfprs) 80*0Sstevel@tonic-gate retl 81*0Sstevel@tonic-gate mov %fprs, %o0 82*0Sstevel@tonic-gate SET_SIZE(_getfprs) 83*0Sstevel@tonic-gate#else 84*0Sstevel@tonic-gate ENTRY(_getpsr) 85*0Sstevel@tonic-gate retl 86*0Sstevel@tonic-gate ta ST_GETPSR 87*0Sstevel@tonic-gate SET_SIZE(_getpsr) 88*0Sstevel@tonic-gate#endif 89*0Sstevel@tonic-gate 90*0Sstevel@tonic-gate ENTRY(_getfsr) 91*0Sstevel@tonic-gate retl 92*0Sstevel@tonic-gate stn %fsr, [%o0] 93*0Sstevel@tonic-gate SET_SIZE(_getfsr) 94*0Sstevel@tonic-gate 95*0Sstevel@tonic-gate ENTRY(_setfsr) 96*0Sstevel@tonic-gate retl 97*0Sstevel@tonic-gate ldn [%o0], %fsr 98*0Sstevel@tonic-gate SET_SIZE(_setfsr) 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate ENTRY(_flush_windows) 101*0Sstevel@tonic-gate retl 102*0Sstevel@tonic-gate ta ST_FLUSH_WINDOWS 103*0Sstevel@tonic-gate SET_SIZE(_flush_windows) 104*0Sstevel@tonic-gate 105*0Sstevel@tonic-gate ENTRY(__lwp_park) 106*0Sstevel@tonic-gate mov %o1, %o2 107*0Sstevel@tonic-gate mov %o0, %o1 108*0Sstevel@tonic-gate mov 0, %o0 109*0Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 110*0Sstevel@tonic-gate SYSLWPERR 111*0Sstevel@tonic-gate RET 112*0Sstevel@tonic-gate SET_SIZE(__lwp_park) 113*0Sstevel@tonic-gate 114*0Sstevel@tonic-gate ENTRY(__lwp_unpark) 115*0Sstevel@tonic-gate mov %o0, %o1 116*0Sstevel@tonic-gate mov 1, %o0 117*0Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 118*0Sstevel@tonic-gate SYSLWPERR 119*0Sstevel@tonic-gate RET 120*0Sstevel@tonic-gate SET_SIZE(__lwp_unpark) 121*0Sstevel@tonic-gate 122*0Sstevel@tonic-gate ENTRY(__lwp_unpark_all) 123*0Sstevel@tonic-gate mov %o1, %o2 124*0Sstevel@tonic-gate mov %o0, %o1 125*0Sstevel@tonic-gate mov 2, %o0 126*0Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 127*0Sstevel@tonic-gate SYSLWPERR 128*0Sstevel@tonic-gate RET 129*0Sstevel@tonic-gate SET_SIZE(__lwp_unpark_all) 130*0Sstevel@tonic-gate 131*0Sstevel@tonic-gate ENTRY(lwp_yield) 132*0Sstevel@tonic-gate SYSTRAP_RVAL1(yield) 133*0Sstevel@tonic-gate RET 134*0Sstevel@tonic-gate SET_SIZE(lwp_yield) 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate/* 137*0Sstevel@tonic-gate * __sighndlr(int sig, siginfo_t *si, ucontex_t *uc, void (*hndlr)()) 138*0Sstevel@tonic-gate * 139*0Sstevel@tonic-gate * This is called from sigacthandler() for the entire purpose of 140*0Sstevel@tonic-gate * communicating the ucontext to java's stack tracing functions. 141*0Sstevel@tonic-gate */ 142*0Sstevel@tonic-gate ENTRY(__sighndlr) 143*0Sstevel@tonic-gate .globl __sighndlrend 144*0Sstevel@tonic-gate save %sp, -SA(MINFRAME), %sp 145*0Sstevel@tonic-gate mov %i0, %o0 146*0Sstevel@tonic-gate mov %i1, %o1 147*0Sstevel@tonic-gate jmpl %i3, %o7 148*0Sstevel@tonic-gate mov %i2, %o2 149*0Sstevel@tonic-gate ret 150*0Sstevel@tonic-gate restore 151*0Sstevel@tonic-gate__sighndlrend: 152*0Sstevel@tonic-gate SET_SIZE(__sighndlr) 153*0Sstevel@tonic-gate 154*0Sstevel@tonic-gate/* 155*0Sstevel@tonic-gate * int _sigsetjmp(sigjmp_buf env, int savemask) 156*0Sstevel@tonic-gate * 157*0Sstevel@tonic-gate * This version is faster than the old non-threaded version because we 158*0Sstevel@tonic-gate * don't normally have to call __getcontext() to get the signal mask. 159*0Sstevel@tonic-gate * (We have a copy of it in the ulwp_t structure.) 160*0Sstevel@tonic-gate */ 161*0Sstevel@tonic-gate 162*0Sstevel@tonic-gate#undef sigsetjmp 163*0Sstevel@tonic-gate 164*0Sstevel@tonic-gate ENTRY2(sigsetjmp,_sigsetjmp) 165*0Sstevel@tonic-gate stn %sp, [%o0 + SJS_SP] ! save caller's sp into env->sjs_sp 166*0Sstevel@tonic-gate add %o7, 8, %o2 ! calculate caller's return pc 167*0Sstevel@tonic-gate stn %o2, [%o0 + SJS_PC] ! save caller's pc into env->sjs_pc 168*0Sstevel@tonic-gate stn %fp, [%o0 + SJS_FP] ! save caller's return linkage 169*0Sstevel@tonic-gate stn %i7, [%o0 + SJS_I7] 170*0Sstevel@tonic-gate call __csigsetjmp 171*0Sstevel@tonic-gate sub %o2, 8, %o7 ! __csigsetjmp returns to caller 172*0Sstevel@tonic-gate SET_SIZE(sigsetjmp) 173*0Sstevel@tonic-gate SET_SIZE(_sigsetjmp) 174