xref: /titanic_50/usr/src/lib/libc/i386/threads/asm_subr.s (revision 9512fe850e98fdd448c638ca63fdd92a8a510255)
1/*
2 * CDDL HEADER START
3 *
4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License").  You may not use this file except in compliance
7 * with the License.
8 *
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
13 *
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
19 *
20 * CDDL HEADER END
21 */
22/*
23 * Copyright 2005 Sun Microsystems, Inc.  All rights reserved.
24 * Use is subject to license terms.
25 */
26
27#pragma ident	"%Z%%M%	%I%	%E% SMI"
28
29	.file	"%M%"
30
31#include <SYS.h>
32
33	/ This is where execution resumes when a thread created with
34	/ thr_create() or pthread_create() returns (see setup_context()).
35	/ We pass the (void *) return value to _thr_terminate().
36	ENTRY(_lwp_start)
37	addl	$4, %esp
38	pushl	%eax
39	call	_thr_terminate
40	addl	$4, %esp	/ actually, never returns
41	SET_SIZE(_lwp_start)
42
43	/ All we need to do now is (carefully) call lwp_exit().
44	ENTRY(_lwp_terminate)
45	SYSTRAP_RVAL1(lwp_exit)
46	RET		/ if we return, it is very bad
47	SET_SIZE(_lwp_terminate)
48
49	ENTRY(set_curthread)
50	movl	4(%esp), %eax
51	movl	%eax, %gs:0
52	ret
53	SET_SIZE(set_curthread)
54
55	ENTRY(__lwp_park)
56	popl	%edx		/ add subcode; save return address
57	pushl	$0
58	pushl	%edx
59	SYSTRAP_RVAL1(lwp_park)
60	SYSLWPERR
61	popl	%edx		/ restore return address
62	movl	%edx, 0(%esp)
63	RET
64	SET_SIZE(__lwp_park)
65
66	ENTRY(__lwp_unpark)
67	popl	%edx		/ add subcode; save return address
68	pushl	$1
69	pushl	%edx
70	SYSTRAP_RVAL1(lwp_park)
71	SYSLWPERR
72	popl	%edx		/ restore return address
73	movl	%edx, 0(%esp)
74	RET
75	SET_SIZE(__lwp_unpark)
76
77	ENTRY(__lwp_unpark_all)
78	popl	%edx		/ add subcode; save return address
79	pushl	$2
80	pushl	%edx
81	SYSTRAP_RVAL1(lwp_park)
82	SYSLWPERR
83	popl	%edx		/ restore return address
84	movl	%edx, 0(%esp)
85	RET
86	SET_SIZE(__lwp_unpark_all)
87
88	ENTRY(lwp_yield)
89	SYSTRAP_RVAL1(yield)
90	RETC
91	SET_SIZE(lwp_yield)
92
93/*
94 * __sighndlr(int sig, siginfo_t *si, ucontext_t *uc, void (*hndlr)())
95 *
96 * This is called from sigacthandler() for the entire purpose of
97 * communicating the ucontext to java's stack tracing functions.
98 */
99	ENTRY(__sighndlr)
100	.globl	__sighndlrend
101	pushl	%ebp
102	movl	%esp, %ebp
103	pushl	16(%ebp)
104	pushl	12(%ebp)
105	pushl	8(%ebp)
106	call	*20(%ebp)
107	addl	$12, %esp
108	leave
109	ret
110__sighndlrend:
111	SET_SIZE(__sighndlr)
112
113/*
114 * int _sigsetjmp(sigjmp_buf env, int savemask)
115 *
116 * This version is faster than the old non-threaded version because we
117 * don't normally have to call __getcontext() to get the signal mask.
118 * (We have a copy of it in the ulwp_t structure.)
119 */
120
121#undef	sigsetjmp
122
123	ENTRY2(sigsetjmp,_sigsetjmp)	/ EIP already pushed
124	pusha				/ EAX .. EDI
125	push	%ds			/ segment registers
126	push	%es
127	push	%fs
128	push	%gs
129	push	%ss
130	push	%cs
131	/ args:  cs, ss, gs, ..., eip, env, savemask
132	call	__csigsetjmp
133	addl	$56, %esp		/ pop 14 words
134	ret
135	SET_SIZE(sigsetjmp)
136	SET_SIZE(_sigsetjmp)
137