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