xref: /onnv-gate/usr/src/lib/libc/amd64/unwind/unwind_frame.s (revision 11718:6e51fde8034a)
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
57298SMark.J.Nelson@Sun.COM * Common Development and Distribution License (the "License").
67298SMark.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/*
22*11718SRod.Evans@Sun.COM * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
230Sstevel@tonic-gate * Use is subject to license terms.
240Sstevel@tonic-gate */
250Sstevel@tonic-gate
267298SMark.J.Nelson@Sun.COM	.file	"unwind_frame.s"
270Sstevel@tonic-gate
280Sstevel@tonic-gate#ifdef _LIBCRUN_
290Sstevel@tonic-gate#define ENTRY(x) \
300Sstevel@tonic-gate        .text; \
310Sstevel@tonic-gate        .align  8; \
320Sstevel@tonic-gate        .globl  x; \
330Sstevel@tonic-gate        .type   x, @function; \
340Sstevel@tonic-gate	x:
350Sstevel@tonic-gate#define SET_SIZE(x) \
360Sstevel@tonic-gate        .size   x, .-x
370Sstevel@tonic-gate#else
380Sstevel@tonic-gate#include "SYS.h"
390Sstevel@tonic-gate#endif
400Sstevel@tonic-gate
410Sstevel@tonic-gate/*
420Sstevel@tonic-gate * ====================
430Sstevel@tonic-gate * _Unw_capture_regs()
440Sstevel@tonic-gate * --------------------
450Sstevel@tonic-gate *
460Sstevel@tonic-gate *	Given  foo()->ex_throw()->_Unwind_RaiseException()->_Unw_capture_regs()
470Sstevel@tonic-gate *	fills in a register array with FP and the preserved registers
480Sstevel@tonic-gate */
490Sstevel@tonic-gate	ENTRY(_Unw_capture_regs)
500Sstevel@tonic-gate	movq	%rbx,24(%rdi)		/* save preserved registers */
510Sstevel@tonic-gate	movq	%rbp,48(%rdi)
520Sstevel@tonic-gate	movq	%r12,96(%rdi)
530Sstevel@tonic-gate	movq	%r13,104(%rdi)
540Sstevel@tonic-gate	movq	%r14,112(%rdi)
550Sstevel@tonic-gate	movq	%r15,120(%rdi)
560Sstevel@tonic-gate	ret
570Sstevel@tonic-gate	SET_SIZE(_Unw_capture_regs)
580Sstevel@tonic-gate
590Sstevel@tonic-gate/*
600Sstevel@tonic-gate * ====================
610Sstevel@tonic-gate * _Unw_jmp
620Sstevel@tonic-gate * --------------------
630Sstevel@tonic-gate *
640Sstevel@tonic-gate * _Unw_jmp is passed a pc and an array of register values.
650Sstevel@tonic-gate */
660Sstevel@tonic-gate
670Sstevel@tonic-gate	ENTRY(_Unw_jmp)
680Sstevel@tonic-gate	movq	%rdi,%r8		/* save arguments to this func */
690Sstevel@tonic-gate	movq	%rsi,%rax
700Sstevel@tonic-gate	movq	40(%rax),%rdi		/* set handler parameters */
710Sstevel@tonic-gate	movq	32(%rax),%rsi
720Sstevel@tonic-gate	movq	8(%rax),%rdx
730Sstevel@tonic-gate	movq	16(%rax),%rcx
740Sstevel@tonic-gate	movq	24(%rax),%rbx		/* restore preserved registers */
750Sstevel@tonic-gate	movq	96(%rax),%r12
760Sstevel@tonic-gate	movq	104(%rax),%r13
770Sstevel@tonic-gate	movq	112(%rax),%r14
780Sstevel@tonic-gate	movq	120(%rax),%r15
790Sstevel@tonic-gate	movq	48(%rax),%rbp
800Sstevel@tonic-gate	movq	56(%rax),%rsp
81*11718SRod.Evans@Sun.COM	movq	(%rax),%rax
820Sstevel@tonic-gate	jmp	*%r8			/* branch to handler */
830Sstevel@tonic-gate	SET_SIZE(_Unw_jmp)
84