xref: /illumos-gate/usr/src/cmd/sgs/link_audit/common/mach.h (revision fd6d41c5025e9fb45a115fc82d86e9983d1e9fd6)
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 /*
23  * Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
24  */
25 #ifndef _MACH_DOT_H
26 #define	_MACH_DOT_H
27 
28 #include <sys/reg.h>
29 #include <sys/types.h>
30 
31 #ifdef	__cplusplus
32 extern "C" {
33 #endif
34 
35 #if	defined(__sparc)
36 
37 #define	GETARG0(regset)		regset->lr_rego0
38 #define	GETARG1(regset)		regset->lr_rego1
39 #define	GETARG2(regset)		regset->lr_rego2
40 #define	GETARG3(regset)		regset->lr_rego3
41 #define	GETARG4(regset)		regset->lr_rego4
42 #define	GETARG5(regset)		regset->lr_rego5
43 
44 #define	GETFRAME(regset)	regset->lr_rego6
45 #define	GETPREVPC(regset)	regset->lr_rego7
46 
47 #elif	defined(__i386)
48 
49 #define	GETARG0(regset)		(((ulong_t *)regset->lr_esp)[1])
50 #define	GETARG1(regset)		(((ulong_t *)regset->lr_esp)[2])
51 #define	GETARG2(regset)		(((ulong_t *)regset->lr_esp)[3])
52 #define	GETARG3(regset)		(((ulong_t *)regset->lr_esp)[4])
53 #define	GETARG4(regset)		(((ulong_t *)regset->lr_esp)[5])
54 #define	GETARG5(regset)		(((ulong_t *)regset->lr_esp)[6])
55 
56 #define	GETFRAME(regset)	(regset->lr_ebp)
57 #define	GETPREVPC(regset)	(*(uintptr_t *)regset->lr_esp)
58 #elif defined(__amd64)
59 #define	GETARG0(regset)		regset->lr_rdi
60 #define	GETARG1(regset)		regset->lr_rsi
61 #define	GETARG2(regset)		regset->lr_rdx
62 #define	GETARG3(regset)		regset->lr_rcx
63 #define	GETARG4(regset)		regset->lr_r8
64 #define	GETARG5(regset)		regset->lr_r9
65 
66 #define	GETFRAME(regset)	(regset->lr_rbp)
67 #define	GETPREVPC(regset)	(*(uintptr_t *)regset->lr_rsp)
68 #else
69 #error	unsupported architecture!
70 #endif
71 
72 
73 #ifdef	__cplusplus
74 }
75 #endif
76 
77 #endif /* _MACH_DOT_H */
78