Split x86-validate into separate files.
[projects/cmucl/cmucl.git] / src / lisp / x86-validate.h
1 /*
2  *
3  * This code was written as part of the CMU Common Lisp project at
4  * Carnegie Mellon University, and has been placed in the public domain.
5  *
6  */
7
8 #ifndef _X86_VALIDATE_H_
9 #define _X86_VALIDATE_H_
10
11 #if defined(__linux__)
12 #include "x86-validate-linux.h"
13 #endif
14
15 #if defined(DARWIN)
16 #include "x86-validate-darwin.h"
17 #endif
18
19 /*
20  * Also look in compiler/x86/parms.lisp for some of the parameters.
21  *
22  * Address map:
23  *
24  *  FreeBSD:
25  *      0x00000000->0x0E000000  224M C program and memory allocation.
26  *      0x0E000000->0x10000000   32M Foreign segment.
27  *      0x10000000->0x20000000  256M Read-Only Space.
28  *      0x20000000->0x28000000  128M Reserved for shared libraries.
29  *      0x28000000->0x38000000  256M Static Space.
30  *      0x38000000->0x40000000  128M Binding stack growing up.
31  *      0x40000000->0x48000000  128M Control stack growing down.
32  *      0x48000000->0xB0000000 1664M Dynamic Space.
33  *      0xB0000000->0xB1000000       Foreign Linkage Table
34  *      0xE0000000->            256M C stack - Alien stack.
35  *
36  *  OpenBSD:
37  *      0x00000000->0x0E000000  224M C program and memory allocation.
38  *      0x0E000000->0x10000000   32M Foreign segment.
39  *      0x10000000->0x20000000  256M Read-Only Space.
40  *      0x20000000->0x28000000  128M Binding stack growing up.
41  *      0x28000000->0x38000000  256M Static Space.
42  *      0x38000000->0x40000000  128M Control stack growing down.
43  *      0x40000000->0x48000000  128M Reserved for shared libraries.
44  *      0x48000000->0xB0000000 1664M Dynamic Space.
45  *      0xB0000000->0xB1000000   16M Foreign Linkage Table
46  *      0xE0000000->            256M C stack - Alien stack.
47  *
48  *  NetBSD:
49  *      0x00000000->0x0E000000  224M C program and memory allocation.
50  *      0x0E000000->0x10000000   32M Foreign segment.
51  *      0x10000000->0x20000000  256M Read-Only Space.
52  *      0x28000000->0x38000000  256M Static Space.
53  *      0x38000000->0x40000000  128M Binding stack growing up.
54  *      0x40000000->0x48000000  128M Control stack growing down.
55  *      0x48800000->0xB0000000 1656M Dynamic Space.
56  *      0xB0000000->0xB1000000   16M Foreign Linkage Table
57  *      0xE0000000->            256M C stack - Alien stack.
58  *
59  *  Linux:
60  *      0x00000000->0x08000000  128M Unused.
61  *      0x08000000->0x10000000  128M C program and memory allocation.
62  *      0x10000000->0x20000000  256M Read-Only Space.
63  *      0x20000000->0x28000000  128M Binding stack growing up.
64  *      0x28000000->0x38000000  256M Static Space.
65  *      0x38000000->0x40000000  128M Control stack growing down.
66  *      0x40000000->0x48000000  128M Reserved for shared libraries.
67  *      0x58000000->0x58100000   16M Foreign Linkage Table
68  *      0x58100000->0xBE000000 1631M Dynamic Space.
69  *      0xBFFF0000->0xC0000000       Unknown Linux mapping
70  *
71  *      (Note: 0x58000000 allows us to run on a Linux system on an AMD
72  *      x86-64.  Hence we have a gap of unused memory starting at
73  *      0x48000000.)
74  */
75
76 #ifdef __FreeBSD__
77 #define READ_ONLY_SPACE_START   (0x10000000)
78 #define READ_ONLY_SPACE_SIZE    (0x0ffff000)    /* 256MB - 1 page */
79
80 #define STATIC_SPACE_START      (0x28f00000)
81 #define STATIC_SPACE_SIZE       (0x0f0ff000)    /* 241MB - 1 page */
82
83 #define BINDING_STACK_START     (0x38000000)
84 #define BINDING_STACK_SIZE      (0x07fff000)    /* 128MB - 1 page */
85
86 #define CONTROL_STACK_START     0x40000000
87 #define CONTROL_STACK_SIZE      0x07fd8000      /* 128MB - SIGSTKSZ */
88 #define SIGNAL_STACK_START      0x47fd8000
89 #define SIGNAL_STACK_SIZE       SIGSTKSZ
90
91 #define DYNAMIC_0_SPACE_START   (0x48000000UL)
92 #ifdef GENCGC
93 #define DYNAMIC_SPACE_SIZE      (0x78000000UL)  /* May be up to 1.7 GB */
94 #else
95 #define DYNAMIC_SPACE_SIZE      (0x04000000UL)  /* 64MB */
96 #endif
97 #define DEFAULT_DYNAMIC_SPACE_SIZE      (0x20000000UL)  /* 512MB */
98 #ifdef LINKAGE_TABLE
99 #define FOREIGN_LINKAGE_SPACE_START ((unsigned long) LinkageSpaceStart)
100 #define FOREIGN_LINKAGE_SPACE_SIZE (0x100000UL) /* 1MB */
101 #endif
102 #endif /* __FreeBSD__ */
103
104
105 #ifdef __OpenBSD__
106 #define READ_ONLY_SPACE_START   (0x10000000)
107 #define READ_ONLY_SPACE_SIZE    (0x0ffff000)    /* 256MB - 1 page */
108
109 #define STATIC_SPACE_START      (0x28000000)
110 #define STATIC_SPACE_SIZE       (0x0ffff000)    /* 256MB - 1 page */
111
112 #define BINDING_STACK_START     (0x38000000)
113 #define BINDING_STACK_SIZE      (0x07fff000)    /* 128MB - 1 page */
114
115 #define CONTROL_STACK_START     (0x40000000)
116 #define CONTROL_STACK_SIZE      (0x07fd8000)    /* 128MB - SIGSTKSZ */
117
118 #define SIGNAL_STACK_START      (0x47fd8000)
119 #define SIGNAL_STACK_SIZE       SIGSTKSZ
120
121 #define DYNAMIC_0_SPACE_START   (0x48000000)
122 #ifdef GENCGC
123 #define DYNAMIC_SPACE_SIZE      (0x68000000)    /* 1.625GB */
124 #else
125 #define DYNAMIC_SPACE_SIZE      (0x04000000)    /* 64MB */
126 #endif
127 #define DEFAULT_DYNAMIC_SPACE_SIZE      (0x20000000)    /* 512MB */
128 #endif
129
130 #if defined(__NetBSD__)
131 #define READ_ONLY_SPACE_START   (SpaceStart_TargetReadOnly)
132 #define READ_ONLY_SPACE_SIZE    (0x0ffff000)    /* 256MB - 1 page */
133
134 #define STATIC_SPACE_START      (SpaceStart_TargetStatic)
135 #define STATIC_SPACE_SIZE       (0x0ffff000)    /* 256MB - 1 page */
136
137 #define BINDING_STACK_START     (0x38000000)
138 #define BINDING_STACK_SIZE      (0x07fff000)    /* 128MB - 1 page */
139
140 #define CONTROL_STACK_START     (0x40000000)
141
142 #define CONTROL_STACK_SIZE      (0x07fd8000)    /* 128MB - SIGSTKSZ */
143
144 #define SIGNAL_STACK_START      (0x47fd8000)
145 #define SIGNAL_STACK_SIZE       SIGSTKSZ
146
147 #define DYNAMIC_0_SPACE_START   (SpaceStart_TargetDynamic)
148 #ifdef GENCGC
149 #define DYNAMIC_SPACE_SIZE      (0x67800000U)   /* 1.656GB */
150 #else
151 #define DYNAMIC_SPACE_SIZE      (0x04000000U)   /* 64MB */
152 #endif
153
154 #define DEFAULT_DYNAMIC_SPACE_SIZE      (0x20000000U)   /* 512MB */
155 #ifdef LINKAGE_TABLE
156 #define FOREIGN_LINKAGE_SPACE_START (LinkageSpaceStart)
157 #define FOREIGN_LINKAGE_SPACE_SIZE (0x100000)   /* 1MB */
158 #endif
159
160 #endif /* __NetBSD__ || DARWIN */
161
162 #ifdef SOLARIS
163 /*
164  * The memory map for Solaris/x86 looks roughly like
165  *
166  *      0x08045000->0x08050000   C stack?
167  *      0x08050000->             Code + C heap
168  *      0x10000000->0x20000000   256 MB read-only space
169  *      0x20000000->0x28000000   128M Binding stack growing up.
170  *      0x28000000->0x30000000   256M Static Space.
171  *      0x30000000->0x31000000   16M Foreign linkage table
172  *      0x38000000->0x40000000   128M Control stack growing down.
173  *      0x40000000->0xD0000000   2304M Dynamic Space.
174  *
175  * Starting at 0xd0ce0000 there is some mapped anon memory.  libc
176  * seems to start at 0xd0d40000 and other places.  Looks like memory
177  * above 0xd0ffe000 or so is not mapped.
178  */
179
180 #define READ_ONLY_SPACE_START   (SpaceStart_TargetReadOnly)
181 #define READ_ONLY_SPACE_SIZE    (0x0ffff000)    /* 256MB - 1 page */
182
183 #define STATIC_SPACE_START      (SpaceStart_TargetStatic)
184 #define STATIC_SPACE_SIZE       (0x0ffff000)    /* 256MB - 1 page */
185
186 #define BINDING_STACK_START     (0x20000000)
187 #define BINDING_STACK_SIZE      (0x07fff000)    /* 128MB - 1 page */
188
189 #define CONTROL_STACK_START     0x38000000
190 #define CONTROL_STACK_SIZE      (0x07fff000 - 8192)
191 #define SIGNAL_STACK_START      CONTROL_STACK_END
192 #define SIGNAL_STACK_SIZE       SIGSTKSZ
193
194 #define DYNAMIC_0_SPACE_START   (SpaceStart_TargetDynamic)
195
196 #ifdef GENCGC
197 #define DYNAMIC_SPACE_SIZE      (0x90000000)    /* 2.304GB */
198 #else
199 #define DYNAMIC_SPACE_SIZE      (0x04000000)    /* 64MB */
200 #endif
201 #define DEFAULT_DYNAMIC_SPACE_SIZE      (0x20000000)    /* 512MB */
202 #ifdef LINKAGE_TABLE
203 #define FOREIGN_LINKAGE_SPACE_START (LinkageSpaceStart)
204 #define FOREIGN_LINKAGE_SPACE_SIZE (0x100000)   /* 1MB */
205 #endif
206 #endif
207
208 #define CONTROL_STACK_END       (CONTROL_STACK_START + control_stack_size)
209
210 /* Note that GENCGC only uses dynamic_space 0. */
211 #define DYNAMIC_1_SPACE_START   (DYNAMIC_0_SPACE_START + DYNAMIC_SPACE_SIZE)
212
213 #endif /* _X86_VALIDATE_H_ */