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
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]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #include <sys/types.h>
32 #if defined(_LP64) || defined(_I32LPx)
39 greg_t fr_savfp; /* saved frame pointer */
40 greg_t fr_savpc; /* saved program counter */
45 * In the x86 world, a stack frame looks like this:
47 * |--------------------------|
48 * 4n+8(%ebp) ->| argument word n |
49 * | ... | (Previous frame)
50 * 8(%ebp) ->| argument word 0 |
51 * |--------------------------|--------------------
52 * 4(%ebp) ->| return address |
53 * |--------------------------|
54 * 0(%ebp) ->| previous %ebp (optional) |
55 * |--------------------------|
56 * -4(%ebp) ->| unspecified | (Current frame)
58 * 0(%esp) ->| variable size |
59 * |--------------------------|
63 * Stack alignment macros.
66 #define STACK_ALIGN32 4
67 #define STACK_ENTRY_ALIGN32 4
68 #define STACK_BIAS32 0
69 #define SA32(x) (((x)+(STACK_ALIGN32-1)) & ~(STACK_ALIGN32-1))
70 #define STACK_RESERVE32 0
76 * In the amd64 world, a stack frame looks like this:
78 * |--------------------------|
79 * 8n+16(%rbp)->| argument word n |
80 * | ... | (Previous frame)
81 * 16(%rbp) ->| argument word 0 |
82 * |--------------------------|--------------------
83 * 8(%rbp) ->| return address |
84 * |--------------------------|
85 * 0(%rbp) ->| previous %rbp |
86 * |--------------------------|
87 * -8(%rbp) ->| unspecified | (Current frame)
89 * 0(%rsp) ->| variable size |
90 * |--------------------------|
91 * -128(%rsp) ->| reserved for function |
92 * |--------------------------|
94 * The end of the input argument area must be aligned on a 16-byte
95 * boundary; i.e. (%rsp - 8) % 16 == 0 at function entry.
97 * The 128-byte location beyond %rsp is considered to be reserved for
98 * functions and is NOT modified by signal handlers. It can be used
99 * to store temporary data that is not needed across function calls.
103 * Stack alignment macros.
106 #define STACK_ALIGN64 16
107 #define STACK_ENTRY_ALIGN64 8
108 #define STACK_BIAS64 0
109 #define SA64(x) (((x)+(STACK_ALIGN64-1)) & ~(STACK_ALIGN64-1))
110 #define STACK_RESERVE64 128
113 #define STACK_ALIGN STACK_ALIGN64
114 #define STACK_ENTRY_ALIGN STACK_ENTRY_ALIGN64
115 #define STACK_BIAS STACK_BIAS64
116 #define SA(x) SA64(x)
117 #define STACK_RESERVE STACK_RESERVE64
118 #define MINFRAME MINFRAME64
120 #elif defined(__i386)
122 #define STACK_ALIGN STACK_ALIGN32
123 #define STACK_ENTRY_ALIGN STACK_ENTRY_ALIGN32
124 #define STACK_BIAS STACK_BIAS32
125 #define SA(x) SA32(x)
126 #define STACK_RESERVE STACK_RESERVE32
127 #define MINFRAME MINFRAME32
131 #endif /* _SYS_FRAME_H */