xref: /titanic_50/usr/src/lib/libc/sparc/unwind/unwind_frame.s (revision cd3e933325e68e23516a196a8fea7f49b1e497c3)
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 * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26	.file	"unwind_frame.s"
27
28#include "SYS.h"
29#include <../assym.h>
30
31/* Cancellation/thr_exit() stuff */
32
33/*
34 * _ex_unwind_local(void)
35 *
36 * Called only from _t_cancel().
37 * Unwind two frames and invoke _t_cancel(fp) again.
38 *
39 * Before this the call stack is: f4 f3 f2 f1 _t_cancel
40 * After this the call stack is:  f4 f3 f2 _t_cancel
41 *	(as if "call f1" is replaced by "call _t_cancel(fp)" in f2)
42 */
43	ENTRY(_ex_unwind_local)
44	restore
45	restore
46	ba	_t_cancel		! tailcall _t_cancel(fp)
47	mov	%fp, %o0		! passing the frame pointer
48	SET_SIZE(_ex_unwind_local)
49
50/*
51 * _ex_clnup_handler(void *arg, void (*clnup)(void *))
52 *
53 * Called only from _t_cancel().
54 * Unwind one frame, call the cleanup handler with argument arg from the
55 * restored frame, then jump to _t_cancel(fp) again from the restored frame.
56 */
57	ENTRY(_ex_clnup_handler)
58	mov	%o1, %i1		! handler address -> %o1 after restore
59	restore	%o0, %g0, %o0		! handler arg -> %o0 after restore
60	stn	%o7, [%g7 + UL_UNWIND_RET]	! save caller's return address
61	jmpl	%o1, %o7		! invoke func with arg
62	nop				! and return here
63	ldn	[%g7 + UL_UNWIND_RET], %o7	! restore return address
64	ba	_t_cancel		! tailcall _t_cancel(fp)
65	mov	%fp, %o0		! passing the frame pointer
66	SET_SIZE(_ex_clnup_handler)
67
68/*
69 * _thrp_unwind(void *arg)
70 *
71 * Ignore the argument; jump to _t_cancel(fp) with caller's fp
72 */
73	ENTRY(_thrp_unwind)
74	ba	_t_cancel		! tailcall _t_cancel(fp)
75	mov	%fp, %o0		! passing the frame pointer
76	SET_SIZE(_thrp_unwind)
77