10Sstevel@tonic-gate/* 20Sstevel@tonic-gate * CDDL HEADER START 30Sstevel@tonic-gate * 40Sstevel@tonic-gate * The contents of this file are subject to the terms of the 56515Sraf * Common Development and Distribution License (the "License"). 66515Sraf * You may not use this file except in compliance with the License. 70Sstevel@tonic-gate * 80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 100Sstevel@tonic-gate * See the License for the specific language governing permissions 110Sstevel@tonic-gate * and limitations under the License. 120Sstevel@tonic-gate * 130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 180Sstevel@tonic-gate * 190Sstevel@tonic-gate * CDDL HEADER END 200Sstevel@tonic-gate */ 216515Sraf 220Sstevel@tonic-gate/* 23*12061SRoger.Faulkner@Oracle.COM * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. 240Sstevel@tonic-gate */ 250Sstevel@tonic-gate 267298SMark.J.Nelson@Sun.COM .file "asm_subr.s" 270Sstevel@tonic-gate 286812Sraf#include "SYS.h" 290Sstevel@tonic-gate#include <sys/trap.h> 300Sstevel@tonic-gate#include <../assym.h> 310Sstevel@tonic-gate 320Sstevel@tonic-gate ! This is where execution resumes when a thread created with 330Sstevel@tonic-gate ! thr_create() or pthread_create() returns (see setup_context()). 346812Sraf ! We pass the (void *) return value to _thrp_terminate(). 350Sstevel@tonic-gate ENTRY(_lwp_start) 360Sstevel@tonic-gate nop ! this is the location from which the func() was "called" 370Sstevel@tonic-gate nop 386812Sraf call _thrp_terminate ! %o0 contains the return value 390Sstevel@tonic-gate nop 400Sstevel@tonic-gate SET_SIZE(_lwp_start) 410Sstevel@tonic-gate 420Sstevel@tonic-gate ENTRY(_lwp_terminate) 430Sstevel@tonic-gate ! Flush the register windows so the stack can be reused. 440Sstevel@tonic-gate ta ST_FLUSH_WINDOWS 450Sstevel@tonic-gate ! All we need to do now is (carefully) call lwp_exit(). 460Sstevel@tonic-gate mov SYS_lwp_exit, %g1 470Sstevel@tonic-gate ta SYSCALL_TRAPNUM 480Sstevel@tonic-gate RET ! if we return, it is very bad 490Sstevel@tonic-gate SET_SIZE(_lwp_terminate) 500Sstevel@tonic-gate 510Sstevel@tonic-gate ENTRY(set_curthread) 520Sstevel@tonic-gate retl 530Sstevel@tonic-gate mov %o0, %g7 540Sstevel@tonic-gate SET_SIZE(set_curthread) 550Sstevel@tonic-gate 560Sstevel@tonic-gate#ifdef __sparcv9 570Sstevel@tonic-gate#define GREGSIZE 8 580Sstevel@tonic-gate#else 590Sstevel@tonic-gate#define GREGSIZE 4 600Sstevel@tonic-gate#endif 610Sstevel@tonic-gate ! void _fetch_globals(greg_t *); 620Sstevel@tonic-gate ! (called from siglongjmp()) 630Sstevel@tonic-gate ENTRY(_fetch_globals) 640Sstevel@tonic-gate stn %g1, [%o0 + 0*GREGSIZE] 650Sstevel@tonic-gate stn %g2, [%o0 + 1*GREGSIZE] 660Sstevel@tonic-gate stn %g3, [%o0 + 2*GREGSIZE] 670Sstevel@tonic-gate stn %g4, [%o0 + 3*GREGSIZE] 680Sstevel@tonic-gate stn %g5, [%o0 + 4*GREGSIZE] 690Sstevel@tonic-gate stn %g6, [%o0 + 5*GREGSIZE] 700Sstevel@tonic-gate retl 710Sstevel@tonic-gate stn %g7, [%o0 + 6*GREGSIZE] 720Sstevel@tonic-gate SET_SIZE(_fetch_globals) 730Sstevel@tonic-gate 740Sstevel@tonic-gate#ifdef __sparcv9 750Sstevel@tonic-gate ENTRY(_getfprs) 760Sstevel@tonic-gate retl 770Sstevel@tonic-gate mov %fprs, %o0 780Sstevel@tonic-gate SET_SIZE(_getfprs) 790Sstevel@tonic-gate#else 800Sstevel@tonic-gate ENTRY(_getpsr) 810Sstevel@tonic-gate retl 820Sstevel@tonic-gate ta ST_GETPSR 830Sstevel@tonic-gate SET_SIZE(_getpsr) 8410629SRoger.Faulkner@Sun.COM 8510629SRoger.Faulkner@Sun.COM ENTRY(_do_fix_align) 8610629SRoger.Faulkner@Sun.COM retl 8710629SRoger.Faulkner@Sun.COM ta ST_FIX_ALIGN 8810629SRoger.Faulkner@Sun.COM SET_SIZE(_do_fix_align) 890Sstevel@tonic-gate#endif 900Sstevel@tonic-gate 910Sstevel@tonic-gate ENTRY(_getfsr) 920Sstevel@tonic-gate retl 930Sstevel@tonic-gate stn %fsr, [%o0] 940Sstevel@tonic-gate SET_SIZE(_getfsr) 950Sstevel@tonic-gate 960Sstevel@tonic-gate ENTRY(_setfsr) 970Sstevel@tonic-gate retl 980Sstevel@tonic-gate ldn [%o0], %fsr 990Sstevel@tonic-gate SET_SIZE(_setfsr) 1000Sstevel@tonic-gate 1010Sstevel@tonic-gate ENTRY(_flush_windows) 1020Sstevel@tonic-gate retl 1030Sstevel@tonic-gate ta ST_FLUSH_WINDOWS 1040Sstevel@tonic-gate SET_SIZE(_flush_windows) 1050Sstevel@tonic-gate 1060Sstevel@tonic-gate ENTRY(__lwp_park) 1070Sstevel@tonic-gate mov %o1, %o2 1080Sstevel@tonic-gate mov %o0, %o1 1090Sstevel@tonic-gate mov 0, %o0 1100Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 1110Sstevel@tonic-gate SYSLWPERR 1120Sstevel@tonic-gate RET 1130Sstevel@tonic-gate SET_SIZE(__lwp_park) 1140Sstevel@tonic-gate 1150Sstevel@tonic-gate ENTRY(__lwp_unpark) 1160Sstevel@tonic-gate mov %o0, %o1 1170Sstevel@tonic-gate mov 1, %o0 1180Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 1190Sstevel@tonic-gate SYSLWPERR 1200Sstevel@tonic-gate RET 1210Sstevel@tonic-gate SET_SIZE(__lwp_unpark) 1220Sstevel@tonic-gate 1230Sstevel@tonic-gate ENTRY(__lwp_unpark_all) 1240Sstevel@tonic-gate mov %o1, %o2 1250Sstevel@tonic-gate mov %o0, %o1 1260Sstevel@tonic-gate mov 2, %o0 1270Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 1280Sstevel@tonic-gate SYSLWPERR 1290Sstevel@tonic-gate RET 1300Sstevel@tonic-gate SET_SIZE(__lwp_unpark_all) 1310Sstevel@tonic-gate 1320Sstevel@tonic-gate/* 1330Sstevel@tonic-gate * __sighndlr(int sig, siginfo_t *si, ucontex_t *uc, void (*hndlr)()) 1340Sstevel@tonic-gate * 1350Sstevel@tonic-gate * This is called from sigacthandler() for the entire purpose of 1360Sstevel@tonic-gate * communicating the ucontext to java's stack tracing functions. 1370Sstevel@tonic-gate */ 1380Sstevel@tonic-gate ENTRY(__sighndlr) 1390Sstevel@tonic-gate .globl __sighndlrend 1400Sstevel@tonic-gate save %sp, -SA(MINFRAME), %sp 1410Sstevel@tonic-gate mov %i0, %o0 1420Sstevel@tonic-gate mov %i1, %o1 1430Sstevel@tonic-gate jmpl %i3, %o7 1440Sstevel@tonic-gate mov %i2, %o2 1450Sstevel@tonic-gate ret 1460Sstevel@tonic-gate restore 1470Sstevel@tonic-gate__sighndlrend: 1480Sstevel@tonic-gate SET_SIZE(__sighndlr) 1490Sstevel@tonic-gate 1500Sstevel@tonic-gate/* 1510Sstevel@tonic-gate * int _sigsetjmp(sigjmp_buf env, int savemask) 1520Sstevel@tonic-gate * 1530Sstevel@tonic-gate * This version is faster than the old non-threaded version because we 1540Sstevel@tonic-gate * don't normally have to call __getcontext() to get the signal mask. 1550Sstevel@tonic-gate * (We have a copy of it in the ulwp_t structure.) 1560Sstevel@tonic-gate */ 1570Sstevel@tonic-gate 1580Sstevel@tonic-gate#undef sigsetjmp 1590Sstevel@tonic-gate 1600Sstevel@tonic-gate ENTRY2(sigsetjmp,_sigsetjmp) 1610Sstevel@tonic-gate stn %sp, [%o0 + SJS_SP] ! save caller's sp into env->sjs_sp 1620Sstevel@tonic-gate add %o7, 8, %o2 ! calculate caller's return pc 1630Sstevel@tonic-gate stn %o2, [%o0 + SJS_PC] ! save caller's pc into env->sjs_pc 1640Sstevel@tonic-gate stn %fp, [%o0 + SJS_FP] ! save caller's return linkage 1650Sstevel@tonic-gate stn %i7, [%o0 + SJS_I7] 166*12061SRoger.Faulkner@Oracle.COM#ifdef __sparcv9 167*12061SRoger.Faulkner@Oracle.COM rd %asi, %o3 168*12061SRoger.Faulkner@Oracle.COM rd %fprs, %o4 169*12061SRoger.Faulkner@Oracle.COM stx %o3, [%o0 + SJS_ASI] 170*12061SRoger.Faulkner@Oracle.COM stx %o4, [%o0 + SJS_FPRS] 171*12061SRoger.Faulkner@Oracle.COM#endif 1720Sstevel@tonic-gate call __csigsetjmp 1730Sstevel@tonic-gate sub %o2, 8, %o7 ! __csigsetjmp returns to caller 1740Sstevel@tonic-gate SET_SIZE(sigsetjmp) 1750Sstevel@tonic-gate SET_SIZE(_sigsetjmp) 176