14856 cmn_err(9F) missing vdev_err()
[illumos-gate.git] / usr / src / uts / sparc / sys / stack.h
blob692832f21e6c938824dd9d34cd89a94d21020009
1 /*
2 * CDDL HEADER START
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.
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.
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]
20 * CDDL HEADER END
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
27 #ifndef _SYS_STACK_H
28 #define _SYS_STACK_H
30 #pragma ident "%Z%%M% %I% %E% SMI"
32 #if !defined(_ASM)
34 #include <sys/types.h>
36 #endif
38 #ifdef __cplusplus
39 extern "C" {
40 #endif
43 * A stack frame looks like:
45 * %fp->| |
46 * |-------------------------------|
47 * | Locals, temps, saved floats |
48 * |-------------------------------|
49 * | outgoing parameters past 6 |
50 * |-------------------------------|-\
51 * | 6 words for callee to dump | |
52 * | register arguments | |
53 * |-------------------------------| > minimum stack frame
54 * | One word struct-ret address | |
55 * |-------------------------------| |
56 * | 16 words to save IN and | |
57 * %sp->| LOCAL register on overflow | |
58 * |-------------------------------|-/
62 * Constants defining a 32-bit stack frame.
64 #define WINDOWSIZE32 (16*4) /* size of window save area */
65 #define ARGPUSHSIZE32 (6*4) /* size of arg dump area */
66 #define ARGPUSH32 (WINDOWSIZE32 + 4) /* arg dump area offset */
67 #define MINFRAME32 (WINDOWSIZE32 + ARGPUSHSIZE32 + 4) /* min frame */
69 #define STACK_GROWTH_DOWN /* stacks grow from high to low addresses */
72 * Stack alignment macros.
74 #define STACK_ALIGN32 8
75 #define STACK_ENTRY_ALIGN32 8
76 #define SA32(X) (((X)+(STACK_ALIGN32-1)) & ~(STACK_ALIGN32-1))
78 #if defined(__sparcv9)
80 * The 64-bit C ABI uses a stack frame that looks like:
82 * | |
83 * |-------------------------------|
84 * | Locals, temps, saved floats |
85 * |-------------------------------|
86 * | outgoing parameters past 6 |
87 * |-------------------------------|-\
88 * | outgoing parameters thru 6 | |
89 * |-------------------------------| > minimum stack frame
90 * | 16 xwords to save IN and | |
91 * | LOCAL register on overflow | |
92 * |-------------------------------|-/-\
93 * | | |
94 * | | > v9 abi bias
95 * | | |
96 * %sp->|-------------------------------|---/
100 * Constants defining a stack frame.
102 #define WINDOWSIZE64 (16*8) /* size of window save area */
103 #define ARGPUSHSIZE64 (6*8) /* size of arg dump area */
104 #define MINFRAME64 (WINDOWSIZE64 + 48) /* min frame */
105 #define ARGPUSH64 (WINDOWSIZE64) /* arg dump area offset */
106 #define V9BIAS64 (2048-1) /* v9 abi stack bias */
108 #define STACK_ALIGN64 16
109 #define STACK_ENTRY_ALIGN64 16
110 #define SA64(X) (((X)+(STACK_ALIGN64-1)) & ~(STACK_ALIGN64-1))
112 #define IS_V9STACK(x) ((((uintptr_t)(x) + V9BIAS64) & \
113 (STACK_ALIGN64-1)) == 0)
115 #define WINDOWSIZE WINDOWSIZE64
116 #define ARGPUSHSIZE ARGPUSHSIZE64
117 #define ARGPUSH ARGPUSH64
118 #define MINFRAME MINFRAME64
119 #define STACK_ALIGN STACK_ALIGN64
120 #define STACK_ENTRY_ALIGN STACK_ENTRY_ALIGN64
121 #define STACK_BIAS V9BIAS64
122 #define SA(x) SA64(x)
124 #else
126 #define WINDOWSIZE WINDOWSIZE32
127 #define ARGPUSHSIZE ARGPUSHSIZE32
128 #define ARGPUSH ARGPUSH32
129 #define MINFRAME MINFRAME32
130 #define STACK_ALIGN STACK_ALIGN32
131 #define STACK_ENTRY_ALIGN STACK_ENTRY_ALIGN32
132 #define STACK_BIAS 0
133 #define SA(x) SA32(x)
134 #define STACK_V9BIAS64 (2048-1) /* v9 abi stack bias */
136 #endif /* __sparcv9 */
138 #if defined(_KERNEL) && !defined(_ASM)
140 #if defined(DEBUG)
141 #if STACK_ALIGN == 8
142 #define ASSERT_STACK_ALIGNED() \
144 uint64_t __tmp; \
145 ASSERT((((uintptr_t)&__tmp) & (STACK_ALIGN - 1)) == 0); \
147 #elif (STACK_ALIGN == 16) && (_LONG_DOUBLE_ALIGNMENT == 16)
148 #define ASSERT_STACK_ALIGNED() \
150 long double __tmp; \
151 ASSERT((((uintptr_t)&__tmp) & (STACK_ALIGN - 1)) == 0); \
153 #endif
154 #else /* DEBUG */
155 #define ASSERT_STACK_ALIGNED()
156 #endif /* DEBUG */
158 struct regs;
160 void flush_windows(void);
161 void flush_user_windows(void);
162 int flush_user_windows_to_stack(caddr_t *);
163 void trash_user_windows(void);
164 void traceregs(struct regs *);
165 void traceback(caddr_t);
167 #endif /* defined(_KERNEL) && !defined(_ASM) */
169 #ifdef __cplusplus
171 #endif
173 #endif /* _SYS_STACK_H */