xref: /titanic_41/usr/src/lib/abi/apptrace/common/mach.h (revision 7c2fbfb345896881c631598ee3852ce9ce33fb07)
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 #ifndef _MACH_H
28 #define	_MACH_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 #include <sys/reg.h>
37 #include <sys/types.h>
38 
39 #if defined(__sparc)
40 
41 #define	GETARG0(regset)		regset->lr_rego0
42 #define	GETARG1(regset)		regset->lr_rego1
43 #define	GETARG2(regset)		regset->lr_rego2
44 #define	GETARG3(regset)		regset->lr_rego3
45 #define	GETARG4(regset)		regset->lr_rego4
46 #define	GETARG5(regset)		regset->lr_rego5
47 
48 #define	GETARG_6NUP(i, regset)	(((ulong_t *)regset->lr_rego6)[23+i-6])
49 
50 #define	GETFRAME(regset)	regset->lr_rego6
51 #define	GETPREVPC(regset)	regset->lr_rego7
52 
53 #elif defined(__amd64)
54 
55 #define	GETARG0(regset)		regset->lr_rdi
56 #define	GETARG1(regset)		regset->lr_rsi
57 #define	GETARG2(regset)		regset->lr_rdx
58 #define	GETARG3(regset)		regset->lr_rcx
59 #define	GETARG4(regset)		regset->lr_r8
60 #define	GETARG5(regset)		regset->lr_r9
61 
62 #define	GETARG_6NUP(i, regset)	(((ulong_t *)regset->lr_rsp)[i+1-6])
63 
64 #define	GETFRAME(regset)	(regset->lr_rbp)
65 #define	GETPREVPC(regset)	(*(uintptr_t *)regset->lr_rsp)
66 
67 #elif defined(i386)
68 
69 #define	GETARG0(regset)		(((ulong_t *)regset->lr_esp)[1])
70 #define	GETARG1(regset)		(((ulong_t *)regset->lr_esp)[2])
71 #define	GETARG2(regset)		(((ulong_t *)regset->lr_esp)[3])
72 #define	GETARG3(regset)		(((ulong_t *)regset->lr_esp)[4])
73 #define	GETARG4(regset)		(((ulong_t *)regset->lr_esp)[5])
74 #define	GETARG5(regset)		(((ulong_t *)regset->lr_esp)[6])
75 
76 #define	GETARG_6NUP(i, regset)	(((ulong_t *)regset->lr_esp)[i+1])
77 
78 #define	GETFRAME(regset)	(regset->lr_ebp)
79 #define	GETPREVPC(regset)	(*(uintptr_t *)regset->lr_esp)
80 #else
81 #error	unsupported architecture!
82 #endif
83 
84 #ifdef	__cplusplus
85 }
86 #endif
87 
88 #endif /* _MACH_H */
89