xref: /illumos-gate/usr/src/uts/i86pc/sys/machparam.h (revision 60a3f738d56f92ae8b80e4b62a2331c6e1f2311f)
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 (the "License").
6  * You may not use this file except in compliance with the License.
7  *
8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9  * or http://www.opensolaris.org/os/licensing.
10  * See the License for the specific language governing permissions
11  * and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL HEADER in each
14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15  * If applicable, add the following below this CDDL HEADER, with the
16  * fields enclosed by brackets "[]" replaced with your own identifying
17  * information: Portions Copyright [yyyy] [name of copyright owner]
18  *
19  * CDDL HEADER END
20  */
21 /*
22  * Copyright 2006 Sun Microsystems, Inc.  All rights reserved.
23  * Use is subject to license terms.
24  */
25 
26 /*	Copyright (c) 1988 AT&T	*/
27 /*	  All Rights Reserved  	*/
28 
29 
30 #ifndef _SYS_MACHPARAM_H
31 #define	_SYS_MACHPARAM_H
32 
33 #pragma ident	"%Z%%M%	%I%	%E% SMI"
34 
35 #if !defined(_ASM)
36 #include <sys/types.h>
37 #endif
38 
39 #ifdef	__cplusplus
40 extern "C" {
41 #endif
42 
43 #ifndef _ASM
44 #define	ADDRESS_C(c)    c ## ul
45 #else   /* _ASM */
46 #define	ADDRESS_C(c)    (c)
47 #endif  /* _ASM */
48 
49 /*
50  * Machine dependent parameters and limits.
51  */
52 #if defined(__amd64)
53 #define	NCPU	64	/* NBBY * sizeof (ulong_t) for simple cpuset_t */
54 #elif defined(__i386)
55 #define	NCPU	32
56 #else
57 #error	"port me"
58 #endif
59 
60 /*
61  * The value defined below could grow to 16. hat structure and
62  * page_t have room for 16 nodes.
63  */
64 #define	MAXNODES 	4
65 #define	NUMA_NODEMASK	0x0f
66 
67 
68 /*
69  * Define the FPU symbol if we could run on a machine with an external
70  * FPU (i.e. not integrated with the normal machine state like the vax).
71  *
72  * The fpu is defined in the architecture manual, and the kernel hides
73  * its absence if it is not present, that's pretty integrated, no?
74  */
75 
76 /* supported page sizes */
77 #define	MMU_PAGE_SIZES	2
78 
79 /*
80  * MMU_PAGES* describes the physical page size used by the mapping hardware.
81  * PAGES* describes the logical page size used by the system.
82  */
83 
84 #define	MMU_PAGESIZE	0x1000		/* 4096 bytes */
85 #define	MMU_PAGESHIFT	12		/* log2(MMU_PAGESIZE) */
86 
87 #if !defined(_ASM)
88 #define	MMU_PAGEOFFSET	(MMU_PAGESIZE-1) /* Mask of address bits in page */
89 #else	/* !_ASM */
90 #define	MMU_PAGEOFFSET	_CONST(MMU_PAGESIZE-1)  /* assembler lameness */
91 #endif	/* !_ASM */
92 
93 #define	MMU_PAGEMASK	(~MMU_PAGEOFFSET)
94 
95 #define	PAGESIZE	0x1000		/* All of the above, for logical */
96 #define	PAGESHIFT	12
97 #define	PAGEOFFSET	(PAGESIZE - 1)
98 #define	PAGEMASK	(~PAGEOFFSET)
99 
100 /*
101  * DATA_ALIGN is used to define the alignment of the Unix data segment.
102  */
103 #define	DATA_ALIGN	PAGESIZE
104 
105 /*
106  * DEFAULT KERNEL THREAD stack size (in pages).
107  */
108 #if defined(__amd64)
109 #define	DEFAULTSTKSZ_NPGS	5
110 #elif defined(__i386)
111 #define	DEFAULTSTKSZ_NPGS	2
112 #endif
113 
114 #if !defined(_ASM)
115 #define	DEFAULTSTKSZ	(DEFAULTSTKSZ_NPGS * PAGESIZE)
116 #else	/* !_ASM */
117 #define	DEFAULTSTKSZ	_MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */
118 #endif	/* !_ASM */
119 
120 /*
121  * KERNELBASE is the virtual address at which the kernel segments start in
122  * all contexts.
123  *
124  * KERNELBASE is not fixed on 32-bit systems.  The value of KERNELBASE can
125  * change with installed memory and the eprom variable 'eprom_kernelbase'.
126  * This value is fixed on 64-bit systems.
127  *
128  * common/conf/param.c requires a compile time defined value for KERNELBASE
129  * which it saves in the variable _kernelbase.  If kernelbase is modifed on
130  * a 32-bit system, _kernelbase will be updated with the new value in
131  * i86pc/os/startup.c.
132  *
133  * i86 and i86pc files use kernelbase instead of KERNELBASE, which is
134  * initialized in i86pc/os/startup.c.
135  */
136 
137 #if defined(__amd64)
138 
139 #define	KERNELBASE	ADDRESS_C(0xfffffd8000000000)
140 
141 /*
142  * Size of the unmapped "red zone" at the very bottom of the kernel's
143  * address space.  Corresponds to 1 slot in the toplevel pagetable.
144  */
145 #define	KERNEL_REDZONE_SIZE   ((uintptr_t)1 << 39)
146 
147 /*
148  * Base of 'core' heap area, which is used for kernel and module text/data
149  * that must be within a 2GB range to allow for rip-relative addressing.
150  *
151  * XX64: because vmx and boot cannot be trusted to stay in a 1GB playpen at
152  * the bottom of the upper 4GB range, we need to restrict the core heap to
153  * the top 1GB for now.
154  */
155 #define	COREHEAP_BASE	ADDRESS_C(0xffffffffc0000000)
156 
157 /*
158  * Beginning of the segkpm window
159  */
160 #define	SEGKPM_BASE	ADDRESS_C(0xfffffe0000000000)
161 
162 /*
163  * default and boundary sizes for segkp
164  */
165 #define	SEGKPDEFSIZE	(2L * 1024L * 1024L * 1024L)		/*   2G */
166 #define	SEGKPMAXSIZE	(8L * 1024L * 1024L * 1024L)		/*   8G */
167 #define	SEGKPMINSIZE	(200L * 1024 * 1024L)			/* 200M */
168 
169 /*
170  * Boot (or, more precisely, vmx) maps most pages twice - once in the
171  * bottom 2GB of memory and once in the bottom 2GB of the topmost 4GB.
172  * When boot is unmapped this range is available to the kernel, but until
173  * then we have to leave it untouched.
174  */
175 #define	BOOT_DOUBLEMAP_BASE	ADDRESS_C(0xffffffff00000000)
176 #define	BOOT_DOUBLEMAP_SIZE	ADDRESS_C(0x80000000)
177 
178 /*
179  * VMWare works best if we don't use the top 64Meg of memory for amd64.
180  * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages.
181  */
182 #define	PROMSTART	ADDRESS_C(0xffc00000)
183 #define	KERNEL_TEXT	ADDRESS_C(0xfffffffffb800000)
184 
185 /*
186  * Define upper limit on user address space
187  *
188  * In amd64, the upper limit on a 64-bit user address space is 1 large page
189  * (2MB) below kernelbase.  The upper limit for a 32-bit user address space
190  * is 1 small page (4KB) below the top of the 32-bit range.  The 64-bit
191  * limit give dtrace the red zone it needs below kernelbase.  The 32-bit
192  * limit gives us a small red zone to detect address-space overruns in a
193  * user program.
194  */
195 #define	USERLIMIT	ADDRESS_C(0xfffffd7fffe00000)
196 #ifdef bug_5074717_is_fixed
197 #define	USERLIMIT32	ADDRESS_C(0xfffff000)
198 #else
199 #define	USERLIMIT32	ADDRESS_C(0xfefff000)
200 #endif
201 
202 #elif defined(__i386)
203 
204 #ifdef DEBUG
205 #define	KERNELBASE	ADDRESS_C(0xc8000000)
206 #else
207 #define	KERNELBASE	ADDRESS_C(0xd4000000)
208 #endif
209 
210 #define	KERNELBASE_MAX	ADDRESS_C(0xe0000000)
211 
212 /*
213  * The i386 ABI requires that the user address space be at least 3Gb
214  * in size.  KERNELBASE_ABI_MIN is used as the default KERNELBASE for
215  * physical memory configurations > 4gb.
216  */
217 #define	KERNELBASE_ABI_MIN	ADDRESS_C(0xc0000000)
218 
219 /*
220  * Size of the unmapped "red zone" at the very bottom of the kernel's
221  * address space.  Since segmap start immediately above the red zone, this
222  * needs to be MAXBSIZE aligned.
223  */
224 #define	KERNEL_REDZONE_SIZE   MAXBSIZE
225 
226 /*
227  * This is the last 4MB of the 4G address space. Some psm modules
228  * need this region of virtual address space mapped 1-1
229  */
230 #define	PROMSTART	ADDRESS_C(0xffc00000)
231 #define	KERNEL_TEXT	ADDRESS_C(0xfe800000)
232 
233 /*
234  * Define upper limit on user address space
235  */
236 #define	USERLIMIT	KERNELBASE
237 #define	USERLIMIT32	USERLIMIT
238 
239 #endif	/* __i386 */
240 
241 #if !defined(_ASM) && !defined(_KADB)
242 extern uintptr_t kernelbase, segkmap_start, segmapsize;
243 #endif
244 
245 /*
246  * ARGSBASE is the base virtual address of the range which
247  * the kernel uses to map the arguments for exec.
248  */
249 #define	ARGSBASE	PROMSTART
250 
251 /*
252  * reserve space for modules
253  */
254 #define	MODTEXT	(1024 * 1024 * 2)
255 #define	MODDATA	(1024 * 300)
256 
257 /*
258  * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
259  * for module text.
260  */
261 #define	HEAPTEXT_SIZE		(64 * 1024 * 1024)	/* bytes */
262 
263 /*
264  * Size of a kernel threads stack.  It must be a whole number of pages
265  * since the segment it comes from will only allocate space in pages.
266  */
267 #define	T_STACKSZ	2*PAGESIZE
268 
269 /*
270  * Size of a cpu startup thread stack.  (It must be a whole number of pages
271  * since the containing segment only allocates space in pages.)
272  */
273 
274 #define	STARTUP_STKSZ	3*PAGESIZE
275 
276 /*
277  * Bus types
278  */
279 #define	BTISA		1
280 #define	BTEISA		2
281 #define	BTMCA		3
282 
283 #ifdef	__cplusplus
284 }
285 #endif
286 
287 #endif	/* _SYS_MACHPARAM_H */
288