| 5ced0fdf |
1 | /* |
| 0d71a1cd |
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 | * |
| 0d71a1cd |
6 | */ |
| 5ced0fdf |
7 | |
| e67c0397 |
8 | #ifndef _X86_VALIDATE_H_ |
| 9 | #define _X86_VALIDATE_H_ |
| 10 | |
| 0d71a1cd |
11 | /* |
| 70fdac9a |
12 | * Also look in compiler/x86/parms.lisp for some of the parameters. |
| 13 | * |
| 0d71a1cd |
14 | * Address map: |
| 15 | * |
| 16 | * FreeBSD: |
| b02a5726 |
17 | * 0x00000000->0x0E000000 224M C program and memory allocation. |
| 18 | * 0x0E000000->0x10000000 32M Foreign segment. |
| 19 | * 0x10000000->0x20000000 256M Read-Only Space. |
| 20 | * 0x20000000->0x28000000 128M Reserved for shared libraries. |
| 21 | * 0x28000000->0x38000000 256M Static Space. |
| 22 | * 0x38000000->0x40000000 128M Binding stack growing up. |
| 23 | * 0x40000000->0x48000000 128M Control stack growing down. |
| 24 | * 0x48000000->0xB0000000 1664M Dynamic Space. |
| 25 | * 0xB0000000->0xB1000000 Foreign Linkage Table |
| 26 | * 0xE0000000-> 256M C stack - Alien stack. |
| 6784e794 |
27 | * |
| 9c76e988 |
28 | * OpenBSD: |
| b02a5726 |
29 | * 0x00000000->0x0E000000 224M C program and memory allocation. |
| 30 | * 0x0E000000->0x10000000 32M Foreign segment. |
| 31 | * 0x10000000->0x20000000 256M Read-Only Space. |
| 32 | * 0x20000000->0x28000000 128M Binding stack growing up. |
| 33 | * 0x28000000->0x38000000 256M Static Space. |
| 34 | * 0x38000000->0x40000000 128M Control stack growing down. |
| 35 | * 0x40000000->0x48000000 128M Reserved for shared libraries. |
| 36 | * 0x48000000->0xB0000000 1664M Dynamic Space. |
| 37 | * 0xB0000000->0xB1000000 16M Foreign Linkage Table |
| 38 | * 0xE0000000-> 256M C stack - Alien stack. |
| 195461c1 |
39 | * |
| 9c76e988 |
40 | * NetBSD: |
| 41 | * 0x00000000->0x0E000000 224M C program and memory allocation. |
| 42 | * 0x0E000000->0x10000000 32M Foreign segment. |
| 43 | * 0x10000000->0x20000000 256M Read-Only Space. |
| 44 | * 0x28000000->0x38000000 256M Static Space. |
| 45 | * 0x38000000->0x40000000 128M Binding stack growing up. |
| 46 | * 0x40000000->0x48000000 128M Control stack growing down. |
| 47 | * 0x48800000->0xB0000000 1656M Dynamic Space. |
| 48 | * 0xB0000000->0xB1000000 16M Foreign Linkage Table |
| 49 | * 0xE0000000-> 256M C stack - Alien stack. |
| 50 | * |
| 300a3dec |
51 | * Linux: |
| b02a5726 |
52 | * 0x00000000->0x08000000 128M Unused. |
| 53 | * 0x08000000->0x10000000 128M C program and memory allocation. |
| 54 | * 0x10000000->0x20000000 256M Read-Only Space. |
| 55 | * 0x20000000->0x28000000 128M Binding stack growing up. |
| 56 | * 0x28000000->0x38000000 256M Static Space. |
| 57 | * 0x38000000->0x40000000 128M Control stack growing down. |
| 58 | * 0x40000000->0x48000000 128M Reserved for shared libraries. |
| 70fdac9a |
59 | * 0x58000000->0x58100000 16M Foreign Linkage Table |
| 60 | * 0x58100000->0xBE000000 1631M Dynamic Space. |
| b02a5726 |
61 | * 0xBFFF0000->0xC0000000 Unknown Linux mapping |
| 0d71a1cd |
62 | * |
| b02a5726 |
63 | * (Note: 0x58000000 allows us to run on a Linux system on an AMD |
| 64 | * x86-64. Hence we have a gap of unused memory starting at |
| 65 | * 0x48000000.) |
| 0d71a1cd |
66 | */ |
| 5ced0fdf |
67 | |
| 6784e794 |
68 | #ifdef __FreeBSD__ |
| 0d71a1cd |
69 | #define READ_ONLY_SPACE_START (0x10000000) |
| 9a8c1c2f |
70 | #define READ_ONLY_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 5ced0fdf |
71 | |
| c90d3517 |
72 | #define STATIC_SPACE_START (0x28f00000) |
| 9a8c1c2f |
73 | #define STATIC_SPACE_SIZE (0x0f0ff000) /* 241MB - 1 page */ |
| 5ced0fdf |
74 | |
| 0d71a1cd |
75 | #define BINDING_STACK_START (0x38000000) |
| 9a8c1c2f |
76 | #define BINDING_STACK_SIZE (0x07fff000) /* 128MB - 1 page */ |
| 6784e794 |
77 | |
| 670d643f |
78 | #define CONTROL_STACK_START 0x40000000 |
| 9a8c1c2f |
79 | #define CONTROL_STACK_SIZE 0x07fd8000 /* 128MB - SIGSTKSZ */ |
| 670d643f |
80 | #define SIGNAL_STACK_START 0x47fd8000 |
| 81 | #define SIGNAL_STACK_SIZE SIGSTKSZ |
| 6784e794 |
82 | |
| 46ecd939 |
83 | #define DYNAMIC_0_SPACE_START (0x48000000UL) |
| 6784e794 |
84 | #ifdef GENCGC |
| 46ecd939 |
85 | #define DYNAMIC_SPACE_SIZE (0x78000000UL) /* May be up to 1.7 GB */ |
| 6784e794 |
86 | #else |
| 46ecd939 |
87 | #define DYNAMIC_SPACE_SIZE (0x04000000UL) /* 64MB */ |
| 4183afd9 |
88 | #endif |
| 46ecd939 |
89 | #define DEFAULT_DYNAMIC_SPACE_SIZE (0x20000000UL) /* 512MB */ |
| bf84be07 |
90 | #ifdef LINKAGE_TABLE |
| 9a8c1c2f |
91 | #define FOREIGN_LINKAGE_SPACE_START ((unsigned long) LinkageSpaceStart) |
| 46ecd939 |
92 | #define FOREIGN_LINKAGE_SPACE_SIZE (0x100000UL) /* 1MB */ |
| 6784e794 |
93 | #endif |
| bf84be07 |
94 | #endif /* __FreeBSD__ */ |
| 6784e794 |
95 | |
| 5ced0fdf |
96 | |
| 5d2cd5df |
97 | #ifdef __OpenBSD__ |
| 195461c1 |
98 | #define READ_ONLY_SPACE_START (0x10000000) |
| 9a8c1c2f |
99 | #define READ_ONLY_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 195461c1 |
100 | |
| 101 | #define STATIC_SPACE_START (0x28000000) |
| 9a8c1c2f |
102 | #define STATIC_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 195461c1 |
103 | |
| 5d2cd5df |
104 | #define BINDING_STACK_START (0x38000000) |
| 9a8c1c2f |
105 | #define BINDING_STACK_SIZE (0x07fff000) /* 128MB - 1 page */ |
| 195461c1 |
106 | |
| 5d2cd5df |
107 | #define CONTROL_STACK_START (0x40000000) |
| 9a8c1c2f |
108 | #define CONTROL_STACK_SIZE (0x07fd8000) /* 128MB - SIGSTKSZ */ |
| 5d2cd5df |
109 | |
| 110 | #define SIGNAL_STACK_START (0x47fd8000) |
| 111 | #define SIGNAL_STACK_SIZE SIGSTKSZ |
| 195461c1 |
112 | |
| 113 | #define DYNAMIC_0_SPACE_START (0x48000000) |
| 114 | #ifdef GENCGC |
| 9a8c1c2f |
115 | #define DYNAMIC_SPACE_SIZE (0x68000000) /* 1.625GB */ |
| 195461c1 |
116 | #else |
| 9a8c1c2f |
117 | #define DYNAMIC_SPACE_SIZE (0x04000000) /* 64MB */ |
| 195461c1 |
118 | #endif |
| 9a8c1c2f |
119 | #define DEFAULT_DYNAMIC_SPACE_SIZE (0x20000000) /* 512MB */ |
| 195461c1 |
120 | #endif |
| 121 | |
| 555746e0 |
122 | #if defined(__NetBSD__) || defined(DARWIN) |
| e4ba8f5e |
123 | #define READ_ONLY_SPACE_START (SpaceStart_TargetReadOnly) |
| 9a8c1c2f |
124 | #define READ_ONLY_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 5d2cd5df |
125 | |
| e4ba8f5e |
126 | #define STATIC_SPACE_START (SpaceStart_TargetStatic) |
| 9a8c1c2f |
127 | #define STATIC_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 5d2cd5df |
128 | |
| 129 | #define BINDING_STACK_START (0x38000000) |
| 9a8c1c2f |
130 | #define BINDING_STACK_SIZE (0x07fff000) /* 128MB - 1 page */ |
| 5d2cd5df |
131 | |
| 132 | #define CONTROL_STACK_START (0x40000000) |
| 5e03034b |
133 | #if defined(DARWIN) |
| 134 | /* |
| 135 | * According to /usr/include/sys/signal.h, MINSIGSTKSZ is 32K and |
| 136 | * SIGSTKSZ is 128K. We should account for that appropriately. |
| 137 | */ |
| 138 | #define CONTROL_STACK_SIZE (0x07fdf000) /* 128MB - SIGSTKSZ - 1 page */ |
| 139 | |
| 140 | #define SIGNAL_STACK_START (0x47fe0000) /* One page past the end of the control stack */ |
| 141 | #define SIGNAL_STACK_SIZE SIGSTKSZ |
| 142 | #else |
| 9a8c1c2f |
143 | #define CONTROL_STACK_SIZE (0x07fd8000) /* 128MB - SIGSTKSZ */ |
| 5d2cd5df |
144 | |
| 145 | #define SIGNAL_STACK_START (0x47fd8000) |
| 146 | #define SIGNAL_STACK_SIZE SIGSTKSZ |
| 5e03034b |
147 | #endif |
| 5d2cd5df |
148 | |
| e4ba8f5e |
149 | #define DYNAMIC_0_SPACE_START (SpaceStart_TargetDynamic) |
| 5d2cd5df |
150 | #ifdef GENCGC |
| abd730c6 |
151 | #if defined(DARWIN) |
| 152 | /* |
| 153 | * On Darwin, /usr/lib/dyld appears to always be loaded at address |
| 154 | * #x8fe2e000. Hence, the maximum dynamic space size is 1206050816 |
| 155 | * bytes, or just over 1.150 GB. Set the limit to 1.150 GB. |
| 156 | */ |
| 157 | #define DYNAMIC_SPACE_SIZE (0x47E00000U) /* 1.150GB */ |
| 158 | #else |
| e4ba8f5e |
159 | #define DYNAMIC_SPACE_SIZE (0x67800000U) /* 1.656GB */ |
| abd730c6 |
160 | #endif |
| 5d2cd5df |
161 | #else |
| e4ba8f5e |
162 | #define DYNAMIC_SPACE_SIZE (0x04000000U) /* 64MB */ |
| 5d2cd5df |
163 | #endif |
| e4ba8f5e |
164 | #define DEFAULT_DYNAMIC_SPACE_SIZE (0x20000000U) /* 512MB */ |
| 5d2cd5df |
165 | #ifdef LINKAGE_TABLE |
| e4ba8f5e |
166 | #define FOREIGN_LINKAGE_SPACE_START (LinkageSpaceStart) |
| 9a8c1c2f |
167 | #define FOREIGN_LINKAGE_SPACE_SIZE (0x100000) /* 1MB */ |
| 5d2cd5df |
168 | #endif |
| 555746e0 |
169 | #endif /* __NetBSD__ || DARWIN */ |
| 195461c1 |
170 | |
| 0d71a1cd |
171 | #ifdef __linux__ |
| 7c0b5c74 |
172 | #define READ_ONLY_SPACE_START (SpaceStart_TargetReadOnly) |
| 9a8c1c2f |
173 | #define READ_ONLY_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 6784e794 |
174 | |
| 7c0b5c74 |
175 | #define STATIC_SPACE_START (SpaceStart_TargetStatic) |
| 9a8c1c2f |
176 | #define STATIC_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 6784e794 |
177 | |
| 245286b7 |
178 | #define BINDING_STACK_START (0x20000000) |
| 9a8c1c2f |
179 | #define BINDING_STACK_SIZE (0x07fff000) /* 128MB - 1 page */ |
| 5ced0fdf |
180 | |
| 670d643f |
181 | #define CONTROL_STACK_START 0x38000000 |
| 9a8c1c2f |
182 | #define CONTROL_STACK_SIZE (0x07fff000 - 8192) |
| 44a8f0c7 |
183 | |
| 670d643f |
184 | #define SIGNAL_STACK_START CONTROL_STACK_END |
| 6438e048 |
185 | #define SIGNAL_STACK_SIZE SIGSTKSZ |
| 0d71a1cd |
186 | |
| 7c0b5c74 |
187 | #define DYNAMIC_0_SPACE_START (SpaceStart_TargetDynamic) |
| 188 | |
| 0c41e522 |
189 | #ifdef GENCGC |
| 9a8c1c2f |
190 | #define DYNAMIC_SPACE_SIZE (0x66000000) /* 1.632GB */ |
| 0c41e522 |
191 | #else |
| 9a8c1c2f |
192 | #define DYNAMIC_SPACE_SIZE (0x04000000) /* 64MB */ |
| 0c41e522 |
193 | #endif |
| 9a8c1c2f |
194 | #define DEFAULT_DYNAMIC_SPACE_SIZE (0x20000000) /* 512MB */ |
| bf84be07 |
195 | #ifdef LINKAGE_TABLE |
| 9a8c1c2f |
196 | #define FOREIGN_LINKAGE_SPACE_START (LinkageSpaceStart) |
| 197 | #define FOREIGN_LINKAGE_SPACE_SIZE (0x100000) /* 1MB */ |
| bf84be07 |
198 | #endif |
| 6784e794 |
199 | #endif |
| 5ced0fdf |
200 | |
| 6438e048 |
201 | #ifdef SOLARIS |
| 202 | /* |
| 203 | * The memory map for Solaris/x86 looks roughly like |
| 204 | * |
| 205 | * 0x08045000->0x08050000 C stack? |
| 206 | * 0x08050000-> Code + C heap |
| 207 | * 0x10000000->0x20000000 256 MB read-only space |
| 208 | * 0x20000000->0x28000000 128M Binding stack growing up. |
| 209 | * 0x28000000->0x30000000 256M Static Space. |
| 210 | * 0x30000000->0x31000000 16M Foreign linkage table |
| 211 | * 0x38000000->0x40000000 128M Control stack growing down. |
| 212 | * 0x40000000->0xD0000000 2304M Dynamic Space. |
| 213 | * |
| 214 | * Starting at 0xd0ce0000 there is some mapped anon memory. libc |
| 215 | * seems to start at 0xd0d40000 and other places. Looks like memory |
| 216 | * above 0xd0ffe000 or so is not mapped. |
| 217 | */ |
| 218 | |
| 219 | #define READ_ONLY_SPACE_START (SpaceStart_TargetReadOnly) |
| 220 | #define READ_ONLY_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 221 | |
| 222 | #define STATIC_SPACE_START (SpaceStart_TargetStatic) |
| 223 | #define STATIC_SPACE_SIZE (0x0ffff000) /* 256MB - 1 page */ |
| 224 | |
| 225 | #define BINDING_STACK_START (0x20000000) |
| 226 | #define BINDING_STACK_SIZE (0x07fff000) /* 128MB - 1 page */ |
| 227 | |
| 228 | #define CONTROL_STACK_START 0x38000000 |
| 229 | #define CONTROL_STACK_SIZE (0x07fff000 - 8192) |
| 230 | #define SIGNAL_STACK_START CONTROL_STACK_END |
| 231 | #define SIGNAL_STACK_SIZE SIGSTKSZ |
| 232 | |
| 233 | #define DYNAMIC_0_SPACE_START (SpaceStart_TargetDynamic) |
| 234 | |
| 235 | #ifdef GENCGC |
| 34b7c7c2 |
236 | #define DYNAMIC_SPACE_SIZE (0x90000000) /* 2.304GB */ |
| 6438e048 |
237 | #else |
| 238 | #define DYNAMIC_SPACE_SIZE (0x04000000) /* 64MB */ |
| 239 | #endif |
| 240 | #define DEFAULT_DYNAMIC_SPACE_SIZE (0x20000000) /* 512MB */ |
| 241 | #ifdef LINKAGE_TABLE |
| 242 | #define FOREIGN_LINKAGE_SPACE_START (LinkageSpaceStart) |
| 243 | #define FOREIGN_LINKAGE_SPACE_SIZE (0x100000) /* 1MB */ |
| 244 | #endif |
| 245 | #endif |
| 245286b7 |
246 | |
| 44a8f0c7 |
247 | #define CONTROL_STACK_END (CONTROL_STACK_START + control_stack_size) |
| 6784e794 |
248 | |
| 249 | /* Note that GENCGC only uses dynamic_space 0. */ |
| 0d71a1cd |
250 | #define DYNAMIC_1_SPACE_START (DYNAMIC_0_SPACE_START + DYNAMIC_SPACE_SIZE) |
| e67c0397 |
251 | |
| 252 | #endif /* _X86_VALIDATE_H_ */ |