xref: /titanic_41/usr/src/cmd/sgs/link_audit/common/mach.h (revision 70025d765b044c6d8594bb965a2247a61e991a99)
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_DOT_H
28 #define	_MACH_DOT_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #include <sys/reg.h>
33 #include <sys/types.h>
34 
35 #ifdef	__cplusplus
36 extern "C" {
37 #endif
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	GETFRAME(regset)	regset->lr_rego6
49 #define	GETPREVPC(regset)	regset->lr_rego7
50 
51 #elif defined(i386)
52 
53 #define	GETARG0(regset)		(((ulong_t *)regset->lr_esp)[1])
54 #define	GETARG1(regset)		(((ulong_t *)regset->lr_esp)[2])
55 #define	GETARG2(regset)		(((ulong_t *)regset->lr_esp)[3])
56 #define	GETARG3(regset)		(((ulong_t *)regset->lr_esp)[4])
57 #define	GETARG4(regset)		(((ulong_t *)regset->lr_esp)[5])
58 #define	GETARG5(regset)		(((ulong_t *)regset->lr_esp)[6])
59 
60 #define	GETFRAME(regset)	(regset->lr_ebp)
61 #define	GETPREVPC(regset)	(*(uintptr_t *)regset->lr_esp)
62 #elif defined(__amd64)
63 #define	GETARG0(regset)		regset->lr_rdi
64 #define	GETARG1(regset)		regset->lr_rsi
65 #define	GETARG2(regset)		regset->lr_rdx
66 #define	GETARG3(regset)		regset->lr_rcx
67 #define	GETARG4(regset)		regset->lr_r8
68 #define	GETARG5(regset)		regset->lr_r9
69 
70 #define	GETFRAME(regset)	(regset->lr_rbp)
71 #define	GETPREVPC(regset)	(*(uintptr_t *)regset->lr_rsp)
72 #else
73 #error	unsupported architecture!
74 #endif
75 
76 
77 #ifdef	__cplusplus
78 }
79 #endif
80 
81 #endif /* _MACH_DOT_H */
82