xref: /titanic_50/usr/src/lib/libproc/common/Pisadep.h (revision fa9e4066f08beec538e775443c5be79dd423fcab)
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	_PISADEP_H
28 #define	_PISADEP_H
29 
30 #pragma ident	"%Z%%M%	%I%	%E% SMI"
31 
32 #ifdef	__cplusplus
33 extern "C" {
34 #endif
35 
36 /*
37  * Internal ISA-dependent functions.
38  *
39  * Note that some ISA-dependent functions are exposed to applications, and found
40  * in libproc.h:
41  *
42  * 	Ppltdest()
43  * 	Pissyscall_prev()
44  * 	Pstack_iter()
45  */
46 
47 /*
48  * ISA dependent function to determine if the instruction at the given address
49  * is a syscall instruction.  On x86, we have multiple system call instructions.
50  * this function returns 1 if there is a system call at the given address, 2 if
51  * there is a less preferred system call, and 0 if there is no system call
52  * there.
53  */
54 extern int Pissyscall(struct ps_prochandle *, uintptr_t);
55 /*
56  * Works the same way as Pissyscall(), except operates on an in-memory buffer.
57  */
58 extern int Pissyscall_text(struct ps_prochandle *, const void *buf,
59     size_t buflen);
60 
61 #if defined(__amd64)
62 /* amd64 stack doubleword aligned, unaligned in 32-bit mode  */
63 #define	PSTACK_ALIGN32(sp)	((sp) & ~(2 * sizeof (int64_t) - 1))
64 #define	PSTACK_ALIGN64(sp)	(sp)
65 #elif defined(__i386)
66 /* i386 stack is unaligned */
67 #define	PSTACK_ALIGN32(sp)	(sp)
68 #define	PSTACK_ALIGN64(sp)	ALIGN32(sp)
69 #elif defined(__sparc)
70 /* sparc stack is doubleword aligned for 64-bit values */
71 #define	PSTACK_ALIGN32(sp)	((sp) & ~(2 * sizeof (int32_t) - 1))
72 #define	PSTACK_ALIGN64(sp)	((sp) & ~(2 * sizeof (int64_t) - 1))
73 #else
74 #error	Unknown ISA
75 #endif
76 
77 /*
78  * Given an argument count, stack pointer, and syscall index, sets up the stack
79  * and appropriate registers.  The stack pointer should be the top of the stack
80  * area, after any space reserved for arguments passed by reference.  Returns a
81  * pointer which is later passed to Psyscall_copyargs().
82  */
83 extern uintptr_t Psyscall_setup(struct ps_prochandle *, int, int, uintptr_t);
84 
85 /*
86  * Copies all arguments out to the stack once we're stopped before the syscall.
87  */
88 extern int Psyscall_copyinargs(struct ps_prochandle *, int, argdes_t *,
89     uintptr_t);
90 
91 /*
92  * Copies out arguments to their original values.
93  */
94 extern int Psyscall_copyoutargs(struct ps_prochandle *, int, argdes_t *,
95     uintptr_t);
96 
97 #ifdef	__cplusplus
98 }
99 #endif
100 
101 #endif	/* _PISADEP_H */
102