a step along the way to setting address space parameters in just one place
[sbcl.git] / src / runtime / x86-validate.h
1 /*
2  * This software is part of the SBCL system. See the README file for
3  * more information.
4  *
5  * This software is derived from the CMU CL system, which was
6  * written at Carnegie Mellon University and released into the
7  * public domain. The software is in the public domain and is
8  * provided with absolutely no warranty. See the COPYING and CREDITS
9  * files for more information.
10  */
11
12 /*
13  * $Header$
14  */
15 \f
16 /*
17  * address map:
18  *
19  *  FreeBSD:
20  *      0x00000000->0x0E000000 224M C program and memory allocation.
21  *      0x0E000000->0x10000000  32M Foreign segment.
22  *      0x10000000->0x20000000 256M Read-Only Space.
23  *      0x20000000->0x30000000 256M Reserved for shared libraries.
24  *      0x30000000->0x38000000 128M Static Space.
25  *      0x38000000->0x40000000 128M Binding stack growing up.
26  *      0x40000000->0x48000000 128M Control stack growing down.
27  *      0x48000000->0xC8000000 2GB  Dynamic Space.
28  *      0xE0000000->           256M C stack - Alien stack.
29  *
30  *  OpenBSD:
31  *      almost the same as FreeBSD
32  *
33  *  Linux: Note that this map has some problems and requires some further
34  *         development so is not implemented below.
35  *      0x00000000->0x08000000 128M Unused.
36  *      0x08000000->0x10000000 128M C program and memory allocation.
37  *      0x10000000->0x20000000 256M Read-Only Space.
38  *      0x20000000->0x28000000 128M Binding stack growing up.
39  *      0x28000000->0x38000000 256M Static Space.
40  *      0x38000000->0x40000000 128M Control stack growing down.
41  *      0x40000000->0x48000000 128M Reserved for shared libraries.
42  *      0x48000000->0xB8000000 1.75G Dynamic Space.
43  *
44  * FIXME: There's something wrong with addressing maps which are so
45  * brittle that they can be commented as fixed addresses. Try to
46  * parameterize these so they can be set at build time.
47  */
48
49 #if defined(__FreeBSD__) || defined(__OpenBSD__)
50 #define READ_ONLY_SPACE_START   (0x10000000)
51 #define READ_ONLY_SPACE_SIZE    (0x0ffff000) /* 256MB - 1 page */
52
53 #if defined __FreeBSD__
54 #define STATIC_SPACE_START      (0x30000000)
55 #define STATIC_SPACE_SIZE       (0x07fff000) /* 128M - 1 page */
56 #elif defined __OpenBSD__
57 #define STATIC_SPACE_START      (0x28000000)
58 #define STATIC_SPACE_SIZE       (0x0ffff000) /* 256M - 1 page */
59 #else
60 #error unsupported BSD variant
61 #endif
62
63
64 #define BINDING_STACK_START     (0x38000000)
65 #define BINDING_STACK_SIZE      (0x07fff000) /* 128MB - 1 page */
66
67 #define CONTROL_STACK_START     (0x40000000)
68 #define CONTROL_STACK_SIZE      (0x08000000) /* 128MB */
69
70 #define DYNAMIC_0_SPACE_START   (0x48000000)
71 #ifdef GENCGC
72 #define DYNAMIC_SPACE_SIZE      (0x40000000) /* May be up to 2GB */
73 #else
74 #define DYNAMIC_SPACE_SIZE      (0x04000000) /* 64MB */
75 #endif
76 #endif
77
78 /* FIXME: It's gross to have numbers like 0x50000000 wired into the
79  * code in multiple places like this. (Not only does this file know
80  * about it, but Lisp code knows about it, because Lisp code is able
81  * to generate absolute addresses for all the static symbols even
82  * before it's read the map file.) I don't know whether I should
83  * actually *fix* this, but I should at least document it some with a
84  * KLUDGE marker. And it might even be fixable, by putting all this
85  * memory space arbitrariness into an architecture-dependent Lisp
86  * file. If so, perhaps I should write somewhere in a "design
87  * principles" or "coding principles" file that information like this
88  * always flows from Lisp code to C code, through sbcl.h. */
89 #ifdef __linux__
90 #define READ_ONLY_SPACE_START   (0x01000000)
91 #define READ_ONLY_SPACE_SIZE    (0x02800000) /* 40MB */
92
93 #define STATIC_SPACE_START      (0x05000000)
94 #define STATIC_SPACE_SIZE       (0x02fff000) /* 48MB - 1 page */
95
96 #define BINDING_STACK_START     (0x60000000)
97 #define BINDING_STACK_SIZE      (0x07fff000) /* 128MB - 1 page */
98
99 #define CONTROL_STACK_START     (0x50000000)
100 #define CONTROL_STACK_SIZE      (0x07fff000) /* 128MB - 1 page */
101
102 #define DYNAMIC_0_SPACE_START   (0x09000000)
103 #ifdef GENCGC
104 #define DYNAMIC_SPACE_SIZE      (0x20000000) /* 512MB */
105 #else
106 #define DYNAMIC_SPACE_SIZE      (0x04000000) /* 64MB */
107 #endif
108 #endif
109
110 #define CONTROL_STACK_END       (CONTROL_STACK_START + CONTROL_STACK_SIZE)
111
112 /* Note that GENCGC only uses dynamic_space 0. */
113 #define DYNAMIC_1_SPACE_START   (DYNAMIC_0_SPACE_START + DYNAMIC_SPACE_SIZE)