xref: /onnv-gate/usr/src/lib/libc/sparc/unwind/unwind_frame.s (revision 7298:b69e27387f74)
10Sstevel@tonic-gate/*
20Sstevel@tonic-gate * CDDL HEADER START
30Sstevel@tonic-gate *
40Sstevel@tonic-gate * The contents of this file are subject to the terms of the
5*7298SMark.J.Nelson@Sun.COM * Common Development and Distribution License (the "License").
6*7298SMark.J.Nelson@Sun.COM * You may not use this file except in compliance with the License.
70Sstevel@tonic-gate *
80Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
90Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing.
100Sstevel@tonic-gate * See the License for the specific language governing permissions
110Sstevel@tonic-gate * and limitations under the License.
120Sstevel@tonic-gate *
130Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each
140Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
150Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the
160Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying
170Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner]
180Sstevel@tonic-gate *
190Sstevel@tonic-gate * CDDL HEADER END
200Sstevel@tonic-gate */
210Sstevel@tonic-gate/*
220Sstevel@tonic-gate * Copyright 2004 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
26*7298SMark.J.Nelson@Sun.COM	.file	"unwind_frame.s"
270Sstevel@tonic-gate
280Sstevel@tonic-gate#include "SYS.h"
290Sstevel@tonic-gate#include <../assym.h>
300Sstevel@tonic-gate
310Sstevel@tonic-gate/* Cancellation/thr_exit() stuff */
320Sstevel@tonic-gate
330Sstevel@tonic-gate/*
340Sstevel@tonic-gate * _ex_unwind_local(void)
350Sstevel@tonic-gate *
360Sstevel@tonic-gate * Called only from _t_cancel().
370Sstevel@tonic-gate * Unwind two frames and invoke _t_cancel(fp) again.
380Sstevel@tonic-gate *
390Sstevel@tonic-gate * Before this the call stack is: f4 f3 f2 f1 _t_cancel
400Sstevel@tonic-gate * After this the call stack is:  f4 f3 f2 _t_cancel
410Sstevel@tonic-gate *	(as if "call f1" is replaced by "call _t_cancel(fp)" in f2)
420Sstevel@tonic-gate */
430Sstevel@tonic-gate	ENTRY(_ex_unwind_local)
440Sstevel@tonic-gate	restore
450Sstevel@tonic-gate	restore
460Sstevel@tonic-gate	ba	_t_cancel		! tailcall _t_cancel(fp)
470Sstevel@tonic-gate	mov	%fp, %o0		! passing the frame pointer
480Sstevel@tonic-gate	SET_SIZE(_ex_unwind_local)
490Sstevel@tonic-gate
500Sstevel@tonic-gate/*
510Sstevel@tonic-gate * _ex_clnup_handler(void *arg, void (*clnup)(void *))
520Sstevel@tonic-gate *
530Sstevel@tonic-gate * Called only from _t_cancel().
540Sstevel@tonic-gate * Unwind one frame, call the cleanup handler with argument arg from the
550Sstevel@tonic-gate * restored frame, then jump to _t_cancel(fp) again from the restored frame.
560Sstevel@tonic-gate */
570Sstevel@tonic-gate	ENTRY(_ex_clnup_handler)
580Sstevel@tonic-gate	mov	%o1, %i1		! handler address -> %o1 after restore
590Sstevel@tonic-gate	restore	%o0, %g0, %o0		! handler arg -> %o0 after restore
600Sstevel@tonic-gate	stn	%o7, [%g7 + UL_UNWIND_RET]	! save caller's return address
610Sstevel@tonic-gate	jmpl	%o1, %o7		! invoke func with arg
620Sstevel@tonic-gate	nop				! and return here
630Sstevel@tonic-gate	ldn	[%g7 + UL_UNWIND_RET], %o7	! restore return address
640Sstevel@tonic-gate	ba	_t_cancel		! tailcall _t_cancel(fp)
650Sstevel@tonic-gate	mov	%fp, %o0		! passing the frame pointer
660Sstevel@tonic-gate	SET_SIZE(_ex_clnup_handler)
670Sstevel@tonic-gate
680Sstevel@tonic-gate/*
690Sstevel@tonic-gate * _thrp_unwind(void *arg)
700Sstevel@tonic-gate *
710Sstevel@tonic-gate * Ignore the argument; jump to _t_cancel(fp) with caller's fp
720Sstevel@tonic-gate */
730Sstevel@tonic-gate	ENTRY(_thrp_unwind)
740Sstevel@tonic-gate	ba	_t_cancel		! tailcall _t_cancel(fp)
750Sstevel@tonic-gate	mov	%fp, %o0		! passing the frame pointer
760Sstevel@tonic-gate	SET_SIZE(_thrp_unwind)
77