xref: /titanic_44/usr/src/uts/i86pc/sys/machparam.h (revision 0398691684c2596072212e4ca9d7033ad7ccfa54)
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.  The value of KERNELBASE can change with
124  * installed memory or on 32 bit systems the eprom variable 'eprom_kernelbase'.
125  *
126  * common/conf/param.c requires a compile time defined value for KERNELBASE.
127  * This value is save in the variable _kernelbase.  _kernelbase may then be
128  * modified with to a different value in i86pc/os/startup.c.
129  *
130  * Most code should be using kernelbase, which resolves to a reference to
131  * _kernelbase.
132  */
133 #define	KERNEL_TEXT_amd64	UINT64_C(0xfffffffffb800000)
134 #define	KERNEL_TEXT_i386	ADDRESS_C(0xfe800000)
135 
136 #if defined(__amd64)
137 
138 #define	KERNELBASE	ADDRESS_C(0xfffffd8000000000)
139 
140 /*
141  * Size of the unmapped "red zone" at the very bottom of the kernel's
142  * address space.  Corresponds to 1 slot in the toplevel pagetable.
143  */
144 #define	KERNEL_REDZONE_SIZE   ((uintptr_t)1 << 39)
145 
146 /*
147  * Base of 'core' heap area, which is used for kernel and module text/data
148  * that must be within a 2GB range to allow for rip-relative addressing.
149  */
150 #define	COREHEAP_BASE	ADDRESS_C(0xffffffffc0000000)
151 
152 /*
153  * Beginning of the segkpm window. A lower value than this is used if
154  * physical addresses exceed 1TB. See i86pc/os/startup.c
155  */
156 #define	SEGKPM_BASE	ADDRESS_C(0xfffffe0000000000)
157 
158 /*
159  * This is valloc_base, above seg_kpm, but below everything else.
160  * A lower value than this may be used if SEGKPM_BASE is adjusted.
161  * See i86pc/os/startup.c
162  */
163 #define	VALLOC_BASE	ADDRESS_C(0xffffff0000000000)
164 
165 /*
166  * default and boundary sizes for segkp
167  */
168 #define	SEGKPDEFSIZE	(2L * 1024L * 1024L * 1024L)		/*   2G */
169 #define	SEGKPMAXSIZE	(8L * 1024L * 1024L * 1024L)		/*   8G */
170 #define	SEGKPMINSIZE	(200L * 1024 * 1024L)			/* 200M */
171 
172 /*
173  * minimum size for segzio
174  */
175 #define	SEGZIOMINSIZE	(400L * 1024 * 1024L)			/* 400M */
176 #define	SEGZIOMAXSIZE	(512L * 1024L * 1024L * 1024L)		/* 512G */
177 
178 /*
179  * During intial boot we limit heap to the top 4Gig.
180  */
181 #define	BOOT_KERNELHEAP_BASE	ADDRESS_C(0xffffffff00000000)
182 
183 /*
184  * VMWare works best if we don't use the top 64Meg of memory for amd64.
185  * Set KERNEL_TEXT to top_o_memory - 64Meg - 8 Meg for 8Meg of nucleus pages.
186  */
187 #define	PROMSTART	ADDRESS_C(0xffc00000)
188 #define	KERNEL_TEXT	KERNEL_TEXT_amd64
189 
190 /*
191  * Virtual address range available to the debugger
192  */
193 #define	SEGDEBUGBASE	ADDRESS_C(0xffffffffff800000)
194 #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
195 
196 /*
197  * Define upper limit on user address space
198  *
199  * In amd64, the upper limit on a 64-bit user address space is 1 large page
200  * (2MB) below kernelbase.  The upper limit for a 32-bit user address space
201  * is 1 small page (4KB) below the top of the 32-bit range.  The 64-bit
202  * limit give dtrace the red zone it needs below kernelbase.  The 32-bit
203  * limit gives us a small red zone to detect address-space overruns in a
204  * user program.
205  */
206 #define	USERLIMIT	ADDRESS_C(0xfffffd7fffe00000)
207 #ifdef bug_5074717_is_fixed
208 #define	USERLIMIT32	ADDRESS_C(0xfffff000)
209 #else
210 #define	USERLIMIT32	ADDRESS_C(0xfefff000)
211 #endif
212 
213 #elif defined(__i386)
214 
215 #ifdef DEBUG
216 #define	KERNELBASE	ADDRESS_C(0xc8000000)
217 #else
218 #define	KERNELBASE	ADDRESS_C(0xd4000000)
219 #endif
220 
221 #define	KERNELBASE_MAX	ADDRESS_C(0xe0000000)
222 
223 /*
224  * The i386 ABI requires that the user address space be at least 3Gb
225  * in size.  KERNELBASE_ABI_MIN is used as the default KERNELBASE for
226  * physical memory configurations > 4gb.
227  */
228 #define	KERNELBASE_ABI_MIN	ADDRESS_C(0xc0000000)
229 
230 /*
231  * Size of the unmapped "red zone" at the very bottom of the kernel's
232  * address space.  Since segmap start immediately above the red zone, this
233  * needs to be MAXBSIZE aligned.
234  */
235 #define	KERNEL_REDZONE_SIZE   MAXBSIZE
236 
237 /*
238  * This is the last 4MB of the 4G address space. Some psm modules
239  * need this region of virtual address space mapped 1-1
240  */
241 #define	PROMSTART	ADDRESS_C(0xffc00000)
242 #define	KERNEL_TEXT	KERNEL_TEXT_i386
243 
244 /*
245  * Virtual address range available to the debugger
246  * We place it just above the kernel text (4M) and kernel data (4M).
247  */
248 #define	SEGDEBUGBASE	(KERNEL_TEXT + ADDRESS_C(0x800000))
249 #define	SEGDEBUGSIZE	ADDRESS_C(0x400000)
250 
251 /*
252  * Define upper limit on user address space
253  */
254 #define	USERLIMIT	KERNELBASE
255 #define	USERLIMIT32	USERLIMIT
256 
257 #endif	/* __i386 */
258 
259 /*
260  * Reserve two pages just below KERNEL_TEXT for the GDT and debug info page.
261  */
262 #if !defined(_ASM)
263 #define	MISC_VA_BASE (KERNEL_TEXT - MMU_PAGESIZE * 2)
264 #define	GDT_VA	(MISC_VA_BASE)
265 #define	DEBUG_INFO_VA (MISC_VA_BASE + MMU_PAGESIZE)
266 #endif /* !_ASM */
267 
268 #if !defined(_ASM) && !defined(_KMDB)
269 extern uintptr_t kernelbase, segmap_start, segmapsize;
270 #endif
271 
272 /*
273  * ARGSBASE is the base virtual address of the range which
274  * the kernel uses to map the arguments for exec.
275  */
276 #define	ARGSBASE	PROMSTART
277 
278 /*
279  * reserve space for modules
280  */
281 #define	MODTEXT	(1024 * 1024 * 2)
282 #define	MODDATA	(1024 * 300)
283 
284 /*
285  * The heap has a region allocated from it of HEAPTEXT_SIZE bytes specifically
286  * for module text.
287  */
288 #define	HEAPTEXT_SIZE		(64 * 1024 * 1024)	/* bytes */
289 
290 /*
291  * Size of a kernel threads stack.  It must be a whole number of pages
292  * since the segment it comes from will only allocate space in pages.
293  */
294 #define	T_STACKSZ	2*PAGESIZE
295 
296 /*
297  * Size of a cpu startup thread stack.  (It must be a whole number of pages
298  * since the containing segment only allocates space in pages.)
299  */
300 
301 #define	STARTUP_STKSZ	3*PAGESIZE
302 
303 /*
304  * Bus types
305  */
306 #define	BTISA		1
307 #define	BTEISA		2
308 #define	BTMCA		3
309 
310 #ifdef	__cplusplus
311 }
312 #endif
313 
314 #endif	/* _SYS_MACHPARAM_H */
315