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 "%M%" 30*0Sstevel@tonic-gate 31*0Sstevel@tonic-gate#include <SYS.h> 32*0Sstevel@tonic-gate 33*0Sstevel@tonic-gate / This is where execution resumes when a thread created with 34*0Sstevel@tonic-gate / thr_create() or pthread_create() returns (see setup_context()). 35*0Sstevel@tonic-gate / We pass the (void *) return value to _thr_terminate(). 36*0Sstevel@tonic-gate ENTRY(_lwp_start) 37*0Sstevel@tonic-gate addl $4, %esp 38*0Sstevel@tonic-gate pushl %eax 39*0Sstevel@tonic-gate call _thr_terminate 40*0Sstevel@tonic-gate addl $4, %esp / actually, never returns 41*0Sstevel@tonic-gate SET_SIZE(_lwp_start) 42*0Sstevel@tonic-gate 43*0Sstevel@tonic-gate / All we need to do now is (carefully) call lwp_exit(). 44*0Sstevel@tonic-gate ENTRY(_lwp_terminate) 45*0Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_exit) 46*0Sstevel@tonic-gate RET / if we return, it is very bad 47*0Sstevel@tonic-gate SET_SIZE(_lwp_terminate) 48*0Sstevel@tonic-gate 49*0Sstevel@tonic-gate ENTRY(set_curthread) 50*0Sstevel@tonic-gate movl 4(%esp), %eax 51*0Sstevel@tonic-gate movl %eax, %gs:0 52*0Sstevel@tonic-gate ret 53*0Sstevel@tonic-gate SET_SIZE(set_curthread) 54*0Sstevel@tonic-gate 55*0Sstevel@tonic-gate ENTRY(__lwp_park) 56*0Sstevel@tonic-gate popl %edx / add subcode; save return address 57*0Sstevel@tonic-gate pushl $0 58*0Sstevel@tonic-gate pushl %edx 59*0Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 60*0Sstevel@tonic-gate SYSLWPERR 61*0Sstevel@tonic-gate popl %edx / restore return address 62*0Sstevel@tonic-gate movl %edx, 0(%esp) 63*0Sstevel@tonic-gate RET 64*0Sstevel@tonic-gate SET_SIZE(__lwp_park) 65*0Sstevel@tonic-gate 66*0Sstevel@tonic-gate ENTRY(__lwp_unpark) 67*0Sstevel@tonic-gate popl %edx / add subcode; save return address 68*0Sstevel@tonic-gate pushl $1 69*0Sstevel@tonic-gate pushl %edx 70*0Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 71*0Sstevel@tonic-gate SYSLWPERR 72*0Sstevel@tonic-gate popl %edx / restore return address 73*0Sstevel@tonic-gate movl %edx, 0(%esp) 74*0Sstevel@tonic-gate RET 75*0Sstevel@tonic-gate SET_SIZE(__lwp_unpark) 76*0Sstevel@tonic-gate 77*0Sstevel@tonic-gate ENTRY(__lwp_unpark_all) 78*0Sstevel@tonic-gate popl %edx / add subcode; save return address 79*0Sstevel@tonic-gate pushl $2 80*0Sstevel@tonic-gate pushl %edx 81*0Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 82*0Sstevel@tonic-gate SYSLWPERR 83*0Sstevel@tonic-gate popl %edx / restore return address 84*0Sstevel@tonic-gate movl %edx, 0(%esp) 85*0Sstevel@tonic-gate RET 86*0Sstevel@tonic-gate SET_SIZE(__lwp_unpark_all) 87*0Sstevel@tonic-gate 88*0Sstevel@tonic-gate ENTRY(lwp_yield) 89*0Sstevel@tonic-gate SYSTRAP_RVAL1(yield) 90*0Sstevel@tonic-gate RETC 91*0Sstevel@tonic-gate SET_SIZE(lwp_yield) 92*0Sstevel@tonic-gate 93*0Sstevel@tonic-gate/* 94*0Sstevel@tonic-gate * __sighndlr(int sig, siginfo_t *si, ucontext_t *uc, void (*hndlr)()) 95*0Sstevel@tonic-gate * 96*0Sstevel@tonic-gate * This is called from sigacthandler() for the entire purpose of 97*0Sstevel@tonic-gate * communicating the ucontext to java's stack tracing functions. 98*0Sstevel@tonic-gate */ 99*0Sstevel@tonic-gate ENTRY(__sighndlr) 100*0Sstevel@tonic-gate .globl __sighndlrend 101*0Sstevel@tonic-gate pushl %ebp 102*0Sstevel@tonic-gate movl %esp, %ebp 103*0Sstevel@tonic-gate pushl 16(%ebp) 104*0Sstevel@tonic-gate pushl 12(%ebp) 105*0Sstevel@tonic-gate pushl 8(%ebp) 106*0Sstevel@tonic-gate call *20(%ebp) 107*0Sstevel@tonic-gate addl $12, %esp 108*0Sstevel@tonic-gate leave 109*0Sstevel@tonic-gate ret 110*0Sstevel@tonic-gate__sighndlrend: 111*0Sstevel@tonic-gate SET_SIZE(__sighndlr) 112*0Sstevel@tonic-gate 113*0Sstevel@tonic-gate/* 114*0Sstevel@tonic-gate * int _sigsetjmp(sigjmp_buf env, int savemask) 115*0Sstevel@tonic-gate * 116*0Sstevel@tonic-gate * This version is faster than the old non-threaded version because we 117*0Sstevel@tonic-gate * don't normally have to call __getcontext() to get the signal mask. 118*0Sstevel@tonic-gate * (We have a copy of it in the ulwp_t structure.) 119*0Sstevel@tonic-gate */ 120*0Sstevel@tonic-gate 121*0Sstevel@tonic-gate#undef sigsetjmp 122*0Sstevel@tonic-gate 123*0Sstevel@tonic-gate ENTRY2(sigsetjmp,_sigsetjmp) / EIP already pushed 124*0Sstevel@tonic-gate pusha / EAX .. EDI 125*0Sstevel@tonic-gate push %ds / segment registers 126*0Sstevel@tonic-gate push %es 127*0Sstevel@tonic-gate push %fs 128*0Sstevel@tonic-gate push %gs 129*0Sstevel@tonic-gate push %ss 130*0Sstevel@tonic-gate push %cs 131*0Sstevel@tonic-gate / args: cs, ss, gs, ..., eip, env, savemask 132*0Sstevel@tonic-gate call __csigsetjmp 133*0Sstevel@tonic-gate addl $56, %esp / pop 14 words 134*0Sstevel@tonic-gate ret 135*0Sstevel@tonic-gate SET_SIZE(sigsetjmp) 136*0Sstevel@tonic-gate SET_SIZE(_sigsetjmp) 137