xref: /titanic_52/usr/src/lib/libc/amd64/unwind/unwind_frame.s (revision 69112edd987c28fa551d4f8d9362a84a45365f17)
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 2010 Sun Microsystems, Inc.  All rights reserved.
23 * Use is subject to license terms.
24 */
25
26	.file	"unwind_frame.s"
27
28#ifdef _LIBCRUN_
29#define ENTRY(x) \
30        .text; \
31        .align  8; \
32        .globl  x; \
33        .type   x, @function; \
34	x:
35#define SET_SIZE(x) \
36        .size   x, .-x
37#else
38#include "SYS.h"
39#endif
40
41/*
42 * ====================
43 * _Unw_capture_regs()
44 * --------------------
45 *
46 *	Given  foo()->ex_throw()->_Unwind_RaiseException()->_Unw_capture_regs()
47 *	fills in a register array with FP and the preserved registers
48 */
49	ENTRY(_Unw_capture_regs)
50	movq	%rbx,24(%rdi)		/* save preserved registers */
51	movq	%rbp,48(%rdi)
52	movq	%r12,96(%rdi)
53	movq	%r13,104(%rdi)
54	movq	%r14,112(%rdi)
55	movq	%r15,120(%rdi)
56	ret
57	SET_SIZE(_Unw_capture_regs)
58
59/*
60 * ====================
61 * _Unw_jmp
62 * --------------------
63 *
64 * _Unw_jmp is passed a pc and an array of register values.
65 */
66
67	ENTRY(_Unw_jmp)
68	movq	%rdi,%r8		/* save arguments to this func */
69	movq	%rsi,%rax
70	movq	40(%rax),%rdi		/* set handler parameters */
71	movq	32(%rax),%rsi
72	movq	8(%rax),%rdx
73	movq	16(%rax),%rcx
74	movq	24(%rax),%rbx		/* restore preserved registers */
75	movq	96(%rax),%r12
76	movq	104(%rax),%r13
77	movq	112(%rax),%r14
78	movq	120(%rax),%r15
79	movq	48(%rax),%rbp
80	movq	56(%rax),%rsp
81	movq	(%rax),%rax
82	jmp	*%r8			/* branch to handler */
83	SET_SIZE(_Unw_jmp)
84