xref: /titanic_50/usr/src/uts/i86pc/sys/machparam.h (revision 549ec3fff108310966327d1dc9004551b63210b7)
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 2007 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 
53 #if defined(__amd64)
54 #define	NCPU 	64 	/* NBBY * sizeof (ulong_t) for simple cpuset_t */
55 #elif defined(__i386)
56 #define	NCPU	32
57 #endif
58 
59 /*
60  * The value defined below could grow to 16. hat structure and
61  * page_t have room for 16 nodes.
62  */
63 #define	MAXNODES 	4
64 #define	NUMA_NODEMASK	0x0f
65 
66 
67 /*
68  * Define the FPU symbol if we could run on a machine with an external
69  * FPU (i.e. not integrated with the normal machine state like the vax).
70  *
71  * The fpu is defined in the architecture manual, and the kernel hides
72  * its absence if it is not present, that's pretty integrated, no?
73  */
74 
75 /* supported page sizes */
76 #define	MMU_PAGE_SIZES	2
77 
78 /*
79  * MMU_PAGES* describes the physical page size used by the mapping hardware.
80  * PAGES* describes the logical page size used by the system.
81  */
82 
83 #define	MMU_PAGESIZE	0x1000		/* 4096 bytes */
84 #define	MMU_PAGESHIFT	12		/* log2(MMU_PAGESIZE) */
85 
86 #if !defined(_ASM)
87 #define	MMU_PAGEOFFSET	(MMU_PAGESIZE-1) /* Mask of address bits in page */
88 #else	/* _ASM */
89 #define	MMU_PAGEOFFSET	_CONST(MMU_PAGESIZE-1)	/* assembler lameness */
90 #endif	/* _ASM */
91 
92 #define	MMU_PAGEMASK	(~MMU_PAGEOFFSET)
93 
94 #define	PAGESIZE	0x1000		/* All of the above, for logical */
95 #define	PAGESHIFT	12
96 #define	PAGEOFFSET	(PAGESIZE - 1)
97 #define	PAGEMASK	(~PAGEOFFSET)
98 
99 /*
100  * DATA_ALIGN is used to define the alignment of the Unix data segment.
101  */
102 #define	DATA_ALIGN	PAGESIZE
103 
104 /*
105  * DEFAULT KERNEL THREAD stack size (in pages).
106  */
107 #if defined(__amd64)
108 #define	DEFAULTSTKSZ_NPGS	5
109 #elif defined(__i386)
110 #define	DEFAULTSTKSZ_NPGS	2
111 #endif
112 
113 #if !defined(_ASM)
114 #define	DEFAULTSTKSZ	(DEFAULTSTKSZ_NPGS * PAGESIZE)
115 #else	/* !_ASM */
116 #define	DEFAULTSTKSZ	_MUL(DEFAULTSTKSZ_NPGS, PAGESIZE) /* as(1) lameness */
117 #endif	/* !_ASM */
118 
119 /*
120  * KERNELBASE is the virtual address at which the kernel segments start in
121  * all contexts.
122  *
123  * KERNELBASE is not fixed on 32-bit systems.  The value of KERNELBASE can
124  * change with installed memory and the eprom variable 'eprom_kernelbase'.
125  * This value is fixed on 64-bit systems.
126  *
127  * common/conf/param.c requires a compile time defined value for KERNELBASE
128  * which it saves in the variable _kernelbase.  If kernelbase is modifed on
129  * a 32-bit system, _kernelbase will be updated with the new value in
130  * i86pc/os/startup.c.
131  *
132  * i86 and i86pc files use kernelbase instead of KERNELBASE, which is
133  * initialized in i86pc/os/startup.c.
134  */
135 #define	KERNEL_TEXT_amd64	UINT64_C(0xfffffffffb800000)
136 #define	KERNEL_TEXT_i386	ADDRESS_C(0xfe800000)
137 
138 #if defined(__amd64)
139 
140 #define	KERNELBASE	ADDRESS_C(0xfffffd8000000000)
141 
142 /*
143  * Size of the unmapped "red zone" at the very bottom of the kernel's
144  * address space.  Corresponds to 1 slot in the toplevel pagetable.
145  */
146 #define	KERNEL_REDZONE_SIZE   ((uintptr_t)1 << 39)
147 
148 /*
149  * Base of 'core' heap area, which is used for kernel and module text/data
150  * that must be within a 2GB range to allow for rip-relative addressing.
151  *
152  * XX64: because vmx and boot cannot be trusted to stay in a 1GB playpen at
153  * the bottom of the upper 4GB range, we need to restrict the core heap to
154  * the top 1GB for now.
155  */
156 #define	COREHEAP_BASE	ADDRESS_C(0xffffffffc0000000)
157 
158 /*
159  * Beginning of the segkpm window
160  */
161 #define	SEGKPM_BASE	ADDRESS_C(0xfffffe0000000000)
162 
163 /*
164  * This is valloc_base, above seg_kpm, but below everything else
165  */
166 #define	VALLOC_BASE	ADDRESS_C(0xffffff0000000000)
167 
168 /*
169  * default and boundary sizes for segkp
170  */
171 #define	SEGKPDEFSIZE	(2L * 1024L * 1024L * 1024L)		/*   2G */
172 #define	SEGKPMAXSIZE	(8L * 1024L * 1024L * 1024L)		/*   8G */
173 #define	SEGKPMINSIZE	(200L * 1024 * 1024L)			/* 200M */
174 
175 /*
176  * minimum size for segzio
177  */
178 #define	SEGZIOMINSIZE	(400L * 1024 * 1024L)			/* 400M */
179 #define	SEGZIOMAXSIZE	(512L * 1024L * 1024L * 1024L)		/* 512G */
180 
181 /*
182  * During intial boot we limit heap to the top 4Gig.
183  */
184 #define	BOOT_KERNELHEAP_BASE	ADDRESS_C(0xffffffff00000000)
185 
186 /*
187  * VMWare works best if we don't use the top 64Meg of memory for amd64.
188  * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages.
189  */
190 #define	PROMSTART	ADDRESS_C(0xffc00000)
191 #define	KERNEL_TEXT	KERNEL_TEXT_amd64
192 
193 /*
194  * Virtual address range available to the debugger
195  */
196 #define	SEGDEBUGBASE	ADDRESS_C(0xffffffffff800000)
197 #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
198 
199 /*
200  * Define upper limit on user address space
201  *
202  * In amd64, the upper limit on a 64-bit user address space is 1 large page
203  * (2MB) below kernelbase.  The upper limit for a 32-bit user address space
204  * is 1 small page (4KB) below the top of the 32-bit range.  The 64-bit
205  * limit give dtrace the red zone it needs below kernelbase.  The 32-bit
206  * limit gives us a small red zone to detect address-space overruns in a
207  * user program.
208  */
209 #define	USERLIMIT	ADDRESS_C(0xfffffd7fffe00000)
210 #ifdef bug_5074717_is_fixed
211 #define	USERLIMIT32	ADDRESS_C(0xfffff000)
212 #else
213 #define	USERLIMIT32	ADDRESS_C(0xfefff000)
214 #endif
215 
216 #elif defined(__i386)
217 
218 #ifdef DEBUG
219 #define	KERNELBASE	ADDRESS_C(0xc8000000)
220 #else
221 #define	KERNELBASE	ADDRESS_C(0xd4000000)
222 #endif
223 
224 #define	KERNELBASE_MAX	ADDRESS_C(0xe0000000)
225 
226 /*
227  * The i386 ABI requires that the user address space be at least 3Gb
228  * in size.  KERNELBASE_ABI_MIN is used as the default KERNELBASE for
229  * physical memory configurations > 4gb.
230  */
231 #define	KERNELBASE_ABI_MIN	ADDRESS_C(0xc0000000)
232 
233 /*
234  * Size of the unmapped "red zone" at the very bottom of the kernel's
235  * address space.  Since segmap start immediately above the red zone, this
236  * needs to be MAXBSIZE aligned.
237  */
238 #define	KERNEL_REDZONE_SIZE   MAXBSIZE
239 
240 /*
241  * This is the last 4MB of the 4G address space. Some psm modules
242  * need this region of virtual address space mapped 1-1
243  */
244 #define	PROMSTART	ADDRESS_C(0xffc00000)
245 #define	KERNEL_TEXT	KERNEL_TEXT_i386
246 
247 /*
248  * Virtual address range available to the debugger
249  * We place it just above the kernel text (4M) and kernel data (4M).
250  */
251 #define	SEGDEBUGBASE	(KERNEL_TEXT + ADDRESS_C(0x800000))
252 #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
253 
254 /*
255  * Define upper limit on user address space
256  */
257 #define	USERLIMIT	KERNELBASE
258 #define	USERLIMIT32	USERLIMIT
259 
260 #endif	/* __i386 */
261 
262 /*
263  * Reserve two pages just below KERNEL_TEXT for the GDT and debug info page.
264  */
265 #if !defined(_ASM)
266 #define	MISC_VA_BASE (KERNEL_TEXT - MMU_PAGESIZE * 2)
267 #define	GDT_VA	(MISC_VA_BASE)
268 #define	DEBUG_INFO_VA (MISC_VA_BASE + MMU_PAGESIZE)
269 #endif /* !_ASM */
270 
271 #if !defined(_ASM) && !defined(_KMDB)
272 extern uintptr_t kernelbase, segmap_start, segmapsize;
273 #endif
274 
275 /*
276  * ARGSBASE is the base virtual address of the range which
277  * the kernel uses to map the arguments for exec.
278  */
279 #define	ARGSBASE	PROMSTART
280 
281 /*
282  * reserve space for modules
283  */
284 #define	MODTEXT	(1024 * 1024 * 2)
285 #define	MODDATA	(1024 * 300)
286 
287 /*
288  * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
289  * for module text.
290  */
291 #define	HEAPTEXT_SIZE		(64 * 1024 * 1024)	/* bytes */
292 
293 /*
294  * Size of a kernel threads stack.  It must be a whole number of pages
295  * since the segment it comes from will only allocate space in pages.
296  */
297 #define	T_STACKSZ	2*PAGESIZE
298 
299 /*
300  * Size of a cpu startup thread stack.  (It must be a whole number of pages
301  * since the containing segment only allocates space in pages.)
302  */
303 
304 #define	STARTUP_STKSZ	3*PAGESIZE
305 
306 /*
307  * Bus types
308  */
309 #define	BTISA		1
310 #define	BTEISA		2
311 #define	BTMCA		3
312 
313 #ifdef	__cplusplus
314 }
315 #endif
316 
317 #endif	/* _SYS_MACHPARAM_H */
318