xref: /titanic_44/usr/src/lib/libc/i386/threads/asm_subr.s (revision 20e6d5c536ad5b300e7fafb6a92e13040f492977)
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 (the "License").
6 * You may not use this file except in compliance with the License.
7 *
8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 * or http://www.opensolaris.org/os/licensing.
10 * See the License for the specific language governing permissions
11 * and limitations under the License.
12 *
13 * When distributing Covered Code, include this CDDL HEADER in each
14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 * If applicable, add the following below this CDDL HEADER, with the
16 * fields enclosed by brackets "[]" replaced with your own identifying
17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 *
19 * CDDL HEADER END
20 */
21
22/*
23 * Copyright 2008 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 _thrp_terminate().
36	ENTRY(_lwp_start)
37	addl	$4, %esp
38	pushl	%eax
39	call	_thrp_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/*
89 * __sighndlr(int sig, siginfo_t *si, ucontext_t *uc, void (*hndlr)())
90 *
91 * This is called from sigacthandler() for the entire purpose of
92 * communicating the ucontext to java's stack tracing functions.
93 */
94	ENTRY(__sighndlr)
95	.globl	__sighndlrend
96	pushl	%ebp
97	movl	%esp, %ebp
98	pushl	16(%ebp)
99	pushl	12(%ebp)
100	pushl	8(%ebp)
101	call	*20(%ebp)
102	addl	$12, %esp
103	leave
104	ret
105__sighndlrend:
106	SET_SIZE(__sighndlr)
107
108/*
109 * int _sigsetjmp(sigjmp_buf env, int savemask)
110 *
111 * This version is faster than the old non-threaded version because we
112 * don't normally have to call __getcontext() to get the signal mask.
113 * (We have a copy of it in the ulwp_t structure.)
114 */
115
116#undef	sigsetjmp
117
118	ENTRY2(sigsetjmp,_sigsetjmp)	/ EIP already pushed
119	pusha				/ EAX .. EDI
120	push	%ds			/ segment registers
121	push	%es
122	push	%fs
123	push	%gs
124	push	%ss
125	push	%cs
126	/ args:  cs, ss, gs, ..., eip, env, savemask
127	call	__csigsetjmp
128	addl	$56, %esp		/ pop 14 words
129	ret
130	SET_SIZE(sigsetjmp)
131	SET_SIZE(_sigsetjmp)
132