]>
Commit | Line | Data |
---|---|---|
a26baf28 BB |
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 _SYS_FRAME_H | |
d1d7e268 | 28 | #define _SYS_FRAME_H |
a26baf28 BB |
29 | |
30 | #include <sys/types.h> | |
31 | ||
32 | #if defined(_LP64) || defined(_I32LPx) | |
33 | typedef long greg_t; | |
34 | #else | |
35 | typedef int greg_t; | |
36 | #endif | |
37 | ||
38 | struct frame { | |
39 | greg_t fr_savfp; /* saved frame pointer */ | |
40 | greg_t fr_savpc; /* saved program counter */ | |
41 | }; | |
42 | ||
43 | ||
44 | /* | |
45 | * In the x86 world, a stack frame looks like this: | |
46 | * | |
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) | |
57 | * | ... | | |
58 | * 0(%esp) ->| variable size | | |
59 | * |--------------------------| | |
60 | */ | |
61 | ||
62 | /* | |
63 | * Stack alignment macros. | |
64 | */ | |
65 | ||
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 | |
71 | #define MINFRAME32 0 | |
72 | ||
73 | #if defined(__amd64) | |
74 | ||
75 | /* | |
76 | * In the amd64 world, a stack frame looks like this: | |
77 | * | |
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) | |
88 | * | ... | | |
89 | * 0(%rsp) ->| variable size | | |
90 | * |--------------------------| | |
91 | * -128(%rsp) ->| reserved for function | | |
92 | * |--------------------------| | |
93 | * | |
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. | |
96 | * | |
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. | |
100 | */ | |
101 | ||
102 | /* | |
103 | * Stack alignment macros. | |
104 | */ | |
105 | ||
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 | |
111 | #define MINFRAME64 0 | |
112 | ||
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 | |
119 | ||
120 | #elif defined(__i386) | |
121 | ||
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 | |
128 | ||
129 | #endif /* __i386 */ | |
130 | ||
131 | #endif /* _SYS_FRAME_H */ |