17c478bd9Sstevel@tonic-gate/* 27c478bd9Sstevel@tonic-gate * CDDL HEADER START 37c478bd9Sstevel@tonic-gate * 47c478bd9Sstevel@tonic-gate * The contents of this file are subject to the terms of the 58cd45542Sraf * Common Development and Distribution License (the "License"). 68cd45542Sraf * You may not use this file except in compliance with the License. 77c478bd9Sstevel@tonic-gate * 87c478bd9Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 97c478bd9Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 107c478bd9Sstevel@tonic-gate * See the License for the specific language governing permissions 117c478bd9Sstevel@tonic-gate * and limitations under the License. 127c478bd9Sstevel@tonic-gate * 137c478bd9Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 147c478bd9Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 157c478bd9Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 167c478bd9Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 177c478bd9Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 187c478bd9Sstevel@tonic-gate * 197c478bd9Sstevel@tonic-gate * CDDL HEADER END 207c478bd9Sstevel@tonic-gate */ 218cd45542Sraf 227c478bd9Sstevel@tonic-gate/* 23*ebe15f48SRoger A. Faulkner * Copyright 2009 Sun Microsystems, Inc. All rights reserved. 247c478bd9Sstevel@tonic-gate * Use is subject to license terms. 257c478bd9Sstevel@tonic-gate */ 267c478bd9Sstevel@tonic-gate 279a70fc3bSMark J. Nelson .file "asm_subr.s" 287c478bd9Sstevel@tonic-gate 297c478bd9Sstevel@tonic-gate#include <SYS.h> 307c478bd9Sstevel@tonic-gate 317c478bd9Sstevel@tonic-gate / This is where execution resumes when a thread created with 327c478bd9Sstevel@tonic-gate / thr_create() or pthread_create() returns (see setup_context()). 337257d1b4Sraf / We pass the (void *) return value to _thrp_terminate(). 347c478bd9Sstevel@tonic-gate ENTRY(_lwp_start) 357c478bd9Sstevel@tonic-gate addl $4, %esp 367c478bd9Sstevel@tonic-gate pushl %eax 377257d1b4Sraf call _thrp_terminate 387c478bd9Sstevel@tonic-gate addl $4, %esp / actually, never returns 397c478bd9Sstevel@tonic-gate SET_SIZE(_lwp_start) 407c478bd9Sstevel@tonic-gate 417c478bd9Sstevel@tonic-gate / All we need to do now is (carefully) call lwp_exit(). 427c478bd9Sstevel@tonic-gate ENTRY(_lwp_terminate) 437c478bd9Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_exit) 447c478bd9Sstevel@tonic-gate RET / if we return, it is very bad 457c478bd9Sstevel@tonic-gate SET_SIZE(_lwp_terminate) 467c478bd9Sstevel@tonic-gate 477c478bd9Sstevel@tonic-gate ENTRY(set_curthread) 487c478bd9Sstevel@tonic-gate movl 4(%esp), %eax 497c478bd9Sstevel@tonic-gate movl %eax, %gs:0 507c478bd9Sstevel@tonic-gate ret 517c478bd9Sstevel@tonic-gate SET_SIZE(set_curthread) 527c478bd9Sstevel@tonic-gate 537c478bd9Sstevel@tonic-gate ENTRY(__lwp_park) 547c478bd9Sstevel@tonic-gate popl %edx / add subcode; save return address 557c478bd9Sstevel@tonic-gate pushl $0 567c478bd9Sstevel@tonic-gate pushl %edx 577c478bd9Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 587c478bd9Sstevel@tonic-gate SYSLWPERR 597c478bd9Sstevel@tonic-gate popl %edx / restore return address 607c478bd9Sstevel@tonic-gate movl %edx, 0(%esp) 617c478bd9Sstevel@tonic-gate RET 627c478bd9Sstevel@tonic-gate SET_SIZE(__lwp_park) 637c478bd9Sstevel@tonic-gate 647c478bd9Sstevel@tonic-gate ENTRY(__lwp_unpark) 657c478bd9Sstevel@tonic-gate popl %edx / add subcode; save return address 667c478bd9Sstevel@tonic-gate pushl $1 677c478bd9Sstevel@tonic-gate pushl %edx 687c478bd9Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 697c478bd9Sstevel@tonic-gate SYSLWPERR 707c478bd9Sstevel@tonic-gate popl %edx / restore return address 717c478bd9Sstevel@tonic-gate movl %edx, 0(%esp) 727c478bd9Sstevel@tonic-gate RET 737c478bd9Sstevel@tonic-gate SET_SIZE(__lwp_unpark) 747c478bd9Sstevel@tonic-gate 757c478bd9Sstevel@tonic-gate ENTRY(__lwp_unpark_all) 767c478bd9Sstevel@tonic-gate popl %edx / add subcode; save return address 777c478bd9Sstevel@tonic-gate pushl $2 787c478bd9Sstevel@tonic-gate pushl %edx 797c478bd9Sstevel@tonic-gate SYSTRAP_RVAL1(lwp_park) 807c478bd9Sstevel@tonic-gate SYSLWPERR 817c478bd9Sstevel@tonic-gate popl %edx / restore return address 827c478bd9Sstevel@tonic-gate movl %edx, 0(%esp) 837c478bd9Sstevel@tonic-gate RET 847c478bd9Sstevel@tonic-gate SET_SIZE(__lwp_unpark_all) 857c478bd9Sstevel@tonic-gate 867c478bd9Sstevel@tonic-gate/* 877c478bd9Sstevel@tonic-gate * __sighndlr(int sig, siginfo_t *si, ucontext_t *uc, void (*hndlr)()) 887c478bd9Sstevel@tonic-gate * 89*ebe15f48SRoger A. Faulkner * This is called from sigacthandler() for the purpose of 90*ebe15f48SRoger A. Faulkner * communicating the ucontext to java's stack tracing functions 91*ebe15f48SRoger A. Faulkner * and to ensure a 16-byte aligned stack pointer for the benefit 92*ebe15f48SRoger A. Faulkner * of gcc-compiled floating point code 937c478bd9Sstevel@tonic-gate */ 947c478bd9Sstevel@tonic-gate ENTRY(__sighndlr) 957c478bd9Sstevel@tonic-gate .globl __sighndlrend 967c478bd9Sstevel@tonic-gate pushl %ebp 977c478bd9Sstevel@tonic-gate movl %esp, %ebp 98*ebe15f48SRoger A. Faulkner andl $-16,%esp / make sure handler is called with 99*ebe15f48SRoger A. Faulkner subl $4,%esp / a 16-byte aligned stack pointer 1007c478bd9Sstevel@tonic-gate pushl 16(%ebp) 1017c478bd9Sstevel@tonic-gate pushl 12(%ebp) 1027c478bd9Sstevel@tonic-gate pushl 8(%ebp) 1037c478bd9Sstevel@tonic-gate call *20(%ebp) 1047c478bd9Sstevel@tonic-gate leave 1057c478bd9Sstevel@tonic-gate ret 1067c478bd9Sstevel@tonic-gate__sighndlrend: 1077c478bd9Sstevel@tonic-gate SET_SIZE(__sighndlr) 1087c478bd9Sstevel@tonic-gate 1097c478bd9Sstevel@tonic-gate/* 1107c478bd9Sstevel@tonic-gate * int _sigsetjmp(sigjmp_buf env, int savemask) 1117c478bd9Sstevel@tonic-gate * 1127c478bd9Sstevel@tonic-gate * This version is faster than the old non-threaded version because we 1137c478bd9Sstevel@tonic-gate * don't normally have to call __getcontext() to get the signal mask. 1147c478bd9Sstevel@tonic-gate * (We have a copy of it in the ulwp_t structure.) 1157c478bd9Sstevel@tonic-gate */ 1167c478bd9Sstevel@tonic-gate 1177c478bd9Sstevel@tonic-gate#undef sigsetjmp 1187c478bd9Sstevel@tonic-gate 1197c478bd9Sstevel@tonic-gate ENTRY2(sigsetjmp,_sigsetjmp) / EIP already pushed 1207c478bd9Sstevel@tonic-gate pusha / EAX .. EDI 1217c478bd9Sstevel@tonic-gate push %ds / segment registers 1227c478bd9Sstevel@tonic-gate push %es 1237c478bd9Sstevel@tonic-gate push %fs 1247c478bd9Sstevel@tonic-gate push %gs 1257c478bd9Sstevel@tonic-gate push %ss 1267c478bd9Sstevel@tonic-gate push %cs 1277c478bd9Sstevel@tonic-gate / args: cs, ss, gs, ..., eip, env, savemask 1287c478bd9Sstevel@tonic-gate call __csigsetjmp 1297c478bd9Sstevel@tonic-gate addl $56, %esp / pop 14 words 1307c478bd9Sstevel@tonic-gate ret 1317c478bd9Sstevel@tonic-gate SET_SIZE(sigsetjmp) 1327c478bd9Sstevel@tonic-gate SET_SIZE(_sigsetjmp) 133